【问题标题】:Extract PresentationNotes from keynote从主题演讲中提取 PresentationNotes
【发布时间】:2015-07-06 15:34:15
【问题描述】:

我很难使用 JXA(用于 osx 的 Javascript)从主题演讲中提取presentationNotes 我不想使用applescript。除了提取笔记之外,此脚本还有更多功能。

看起来很简单。但是,当我在一个 RichText 对象中获取presentationNotes 时,它似乎无论如何都无法获取普通文本。 所以我想我会打开 textEditor 并将它们写出来。 好吧,我不知道该怎么做。

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() 无关

【问题讨论】:

    标签: javascript applescript osx-yosemite automator javascript-automation


    【解决方案1】:

    你快到了。您不应该推送文本,而是推送文本的段落对象。

    这是一个完整的示例(仅文本)。 它使用当前打开的 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") ) 
    }
    

    【讨论】:

    • 你是如何测试获取文本的?当我做 slide.presenterNotes() 我会得到一个错误。在 shell 中运行它并执行 console.log(notes) 永远不会打印出我会收到错误的文本。今晚我回家后试试。谢谢你。如果我有任何问题,我会告诉你。
    • 没有进行任何测试。我刚才使用脚本编辑器检查,如果幻灯片没有演讲者备注,它会返回“”。
    • 再次感谢。今晚我会回复你,但当我在做 PresentationNotes() 时,我非常肯定它会说不是一个函数。我会让你知道会发生什么。
    • 可能是错字?应该是presenterNotes(),而不是presentationNotes()。
    • 哇,羞愧地低着头哭着睡。
    猜你喜欢
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 2018-09-16
    • 2012-10-22
    • 1970-01-01
    相关资源
    最近更新 更多