0

我正在使用 Adob​​e InDesign CS5 Server Java。为了设置所需的首选项,我使用以下代码:

Document myDocument = myApp.addDocument(OptArg.noDocumentPreset());
DocumentPreference docPrefs = myDocument.getDocumentPreferences();
docPrefs.setPageHeight(UnitUtils.createString("800pt"));
docPrefs.setPageWidth(UnitUtils.createString("600pt"));
docPrefs.setPageOrientation(kPageOrientationLandscape.value);
docPrefs.setPagesPerDocument(16);

我想知道是否可以在不设置 setPagesPerDocument 的情况下以某种方式找出 java 中的真实文档页数?预先感谢您的任何帮助。

4

2 回答 2

0

以防万一。抱歉,我不知道它在 Java 中是如何工作的。但在 Windows 上的 Python 中,可以这样完成:

from win32com.client import Dispatch

app = Dispatch('InDesign.Application.CS6')
doc = app.Open(r"d:\sample.indd")
pages = doc.pages;
pages_length = len(pages)
doc.Close()

print(pages_length)
于 2021-04-28T17:48:06.353 回答
0

您可以像这样简单地找出页数:

var pageCount = myDocument.pages.length

$.writeln("The document has " + pageCount + " pages.");

顺便提一句。InDesign 脚本是用 JavaScript(或者更准确地说是用 JavaScript 方言 ExtendScript)完成的,这是一种与 Java 非常不同的语言。

编辑:好的,回答你的评论,我不知道 InDesignServerAPI.jar 是什么,但看看你的代码,看起来 InDesign ExtendScript 语言只是包装成 Java 代码。所以我的猜测是,你可以获得这样的页数:

int pageCount = myDocument.pages.length;
于 2020-05-25T20:22:49.803 回答