使用InDesign Server将页面导出为png

时间:2011-08-25 18:43:58

标签: indesign-server

有没有办法将页面导出为带有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"));

1 个答案:

答案 0 :(得分: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

修改

查看this article from the Adobe Forums,它指出InDesign可以导出为PNG但不包含任何选项,因此除了指定格式之外,它还有其他限制。所以,如果上面的代码示例没有帮助,可以尝试这样的事情:

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

希望这有帮助!