我很难使用 JXA(osx 的 Javascript)从主题演讲中提取演示笔记,我不想使用 applescript。该脚本的功能远不止提取注释。
看起来很简单。然而,当我得到presentationNotes时,它位于一个RichText对象中,该对象似乎无论如何都无法获取普通文本。 所以我想我应该打开文本编辑器并将它们写入其中。 好吧,我不知道该怎么做。
var app = Application('Keynote')
document = app.documents[0]
slide_name = document.name()
i = 1 // loop through folder contents
folder_name = 'chapter'+i
//create a folder
var textEdit = Application('textEdit')
textEdit.activate()
var doc = textEdit.make({new:'document'})
doc.text = "fsdfsdfs"
var c = 0;
for(slide in document.slides){
var s = document.slides[slide]
var note = s.presentationNotes // returns object specifier
//textEdit.documents[0].push(note)
// I've tried lots of things here.
}
任何想法或帮助将不胜感激。我看过一些 applescript 示例,但是我无法翻译它们。显然,applescript 作为文本与 toString() 无关
最佳答案
你就快到了。您不应该推送文本,而应该推送文本的段落对象。
这是一个完整的示例(仅限文本)。 它使用当前打开的 Keynote 和 TextEdit 文档。
var Keynote = Application("Keynote");
var presentation = Keynote.documents[0];
var TextEdit = Application("TextEdit");
var document = TextEdit.documents[0];
document.paragraphs.push( TextEdit.Paragraph({color:"red", size:18}, "presentation: "+ presentation.name()+"\n" ))
for (var i=0; i<presentation.slides.length; i++) {
slide = presentation.slides[i];
slideTitle = slide.defaultTitleItem().objectText();
notes = slide.presenterNotes(); // text only
document.paragraphs.push( TextEdit.Paragraph({color:"blue", size:14}, "\n"+ (i+1) +": "+ slideTitle + "\n") )
document.paragraphs.push( TextEdit.Paragraph({}, notes +"\n") )
}
关于javascript - 从主题演讲中提取PresentationNotes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29908323/