本文介绍了从主题演讲中提取 PresentationNotes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

看起来很简单.但是,当我在一个 RichText 对象中获取 PresentationNotes 时,该对象似乎没有任何方式来获取普通文本.所以我想我会打开 textEditor 并将它们写出来.好吧,我不知道该怎么做.

var app = Application('Keynote')文档 = app.documents[0]幻灯片名称 = document.name()i = 1//遍历文件夹内容folder_name = '章节'+i//创建一个文件夹var textEdit = Application('textEdit')textEdit.activate()var doc = textEdit.make({new:'document'})doc.text = "fsdfsdfs"无功c = 0;for(幻灯片文档.slides){var s = document.slides[幻灯片]var note = s.presentationNotes//返回对象说明符//textEdit.documents[0].push(note)//我在这里尝试了很多东西.}

任何想法或帮助将不胜感激.我看过一些applescript 示例,但是我无法翻译它们.显然 Applescript 作为文本与 toString()

无关

解决方案

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

这是一个完整的示例(仅文本).它使用当前打开的 Keynote 和 TextEdit 文档.

var Keynote = Application("Keynote");var 演示文稿 = 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

I'm having a hard time extracting presentationNotes from a keynote presentation using JXA (Javascript for osx) I don't want to use applescript. There is way more to this script than extracting notes.

It seems rather simple. However when I get the presentationNotes its in an RichText object that doesn't seem to have anyway to get normal text.So I figured I'd open up textEditor and write them out to it.Well I can't figure out how to do that.

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.


}

Any ideas or help would be appreciated. I've seen some applescript examples, however I couldn't get them to translate. Apparently applescript as text doesn't relate to toString()

解决方案

You were almost there. You should not push the text, but push a paragraph object of the text.

Here is a complete example (text only).It uses the currently open Keynote and TextEdit documents.

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") )
}

这篇关于从主题演讲中提取 PresentationNotes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:31