3

有没有办法使用 InDesign 服务器将页面导出为 png 格式?

以下代码适用于文本框架。我如何对完整的页面内容执行相同的操作?

var theDocument = app.documents.add();
var thePage = theDocument.pages[0];
var theTextFrame = thePage.textFrames.add();
theTextFrame.geometricBounds = [5,5,40,40];
theTextFrame.contents = TextFrameContents.placeholderText;
theTextFrame.exportFile(ExportFormat.pngFormat, File("c:\\test.png"));
4

1 回答 1

1

如果你可以导出为JPG,这样的东西应该可以工作:

//set which page you want to export:
app.jpegExportPreferences.pageString='1';

//export that page from the document:
var myFile = new File('C:/test.jpg');
theDocument.exportFile(ExportFormat.JPG, myFile);

我不确定在jpegExportPreferences.pageString导出为 PNG 时设置是否仍然有效,但您也许可以对其进行测试。希望这至少能让你走上正轨!

请注意,如果要导出为 PNG,请使用以下导出格式:

ExportFormat.PNG_Format

编辑:

查看Adob​​e 论坛中的这篇文章,它指出 InDesign 可以导出为 PNG,但不包含任何选项,因此除了指定格式外,它还有一些限制。所以,如果上面的代码示例没有帮助,也许可以尝试这样的事情:

app.activeDocument.selection[0].exportFile(ExportFormat.PNG_FORMAT, File(new File("c:\\test.png")));

希望这可以帮助!

于 2011-09-06T17:53:09.473 回答