我沒有太多的Indesign經驗可以說,但我被要求調查是否有可能(使用腳本的獨立服務器)啓動一個新文檔,應用一個主文檔擴展頁面,插入一些段落並應用一些段落樣式。應用ParagraphStyle後文本框架消失
我想出瞭解決的辦法是這個
// define template
var indesignTemplate = new File("/e/mytemplate.indt");
// open the template
var doc = app.open(indesignTemplate);
// get master page
var masterPage = doc.masterSpreads.item("A-Master");
// get first page
var page = doc.pages.item(0);
// apply master page to our first page
page.appliedMaster = masterPage
// get paragraph style
var paragraphStyle = doc.paragraphStyles.item("_2.ondertitel_bladzijde");
for (var i = 0; i < masterPage.textFrames.length; i++) {
var textframe = masterPage.textFrames.item(i);
if (textframe.label === "flow") {
for (var x = 0; x < 5; x++) {
// insert another new paragraph
textframe.parentStory.insertionPoints.item(-1).contents = "Lorem ipsum dolor... \r\r";
}
for (var x = 0; x < textframe.paragraphs.length; x++) {
textframe.paragraphs.item(0).applyParagraphStyle(paragraphStyle);
}
}
}
//Save the document (fill in a valid file path).
doc.save(new File("/c/mybook.indd"));
// Save the document as an PDF
doc.exportFile(ExportFormat.pdfType, new File("/c/mybook.pdf"));
// close the document.
app.documents.item(0).close();
這個工作,可以看到我的文字時我註釋掉的代碼applyParagraphStyle。
從我嘗試應用paragraphStyle的那一刻起,文本就會隱藏起來。當我然後在Indesign中打開保存的indd文件,然後在空白文本框中單擊命令+ shift,文本出現,我也看到一個額外的圖層出現。
我也嘗試應用CharacterStyles或多或少相同的方式,但不會給任何問題。
我認爲問題在於我可能以錯誤的方式接近這個事實?
嘗試添加textframe.recompose()到你的循環 –
相同的行爲不幸:( –