从主题提取presentationNotes [英] Extract PresentationNotes from keynote

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

问题描述

我有一个很难使用JXA(JavaScript进行OSX)的主旨presentation提取presentationNotes我不希望使用的AppleScript。没有比提取票据的方式更多的这个脚本。

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.

这似乎相当简单。然而,当我拿到presentationNotes其在富文本对象,似乎并没有无论如何都要得到普通文本。
所以,我想我会打开文本编辑并把它们写出来给它。
好吧,我无法弄清楚如何做到这一点。

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.


}

任何意见或帮助将是AP preciated。我见过一些例子的AppleScript,但我不能让他们翻译。显然,AppleScript的文本不涉及到的toString()

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆