forked from lohriialo/indesign-server-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_pdf.jsx
More file actions
48 lines (39 loc) · 1.17 KB
/
export_pdf.jsx
File metadata and controls
48 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function ExportAsPDF(myFile){
try{
app.documents.item(0).exportFile(ExportFormat.pdfType, myFile, app.pdfExportPresets.item("[High Quality Print]"));
}catch(e){
alert(e);
};
}
function LoadDataIntoTemplate(doc){
// using script label to place data into placeholders
for (var idx = 0; idx < doc.allPageItems.length; idx++)
{
var pageItem = doc.allPageItems[idx];
// Editorial contents
if (pageItem.constructor.name == "TextFrame" && pageItem.label == "placeholder1")
{
pageItem.contents = app.scriptArgs.getValue("arg1");
}
if (pageItem.constructor.name == "TextFrame" && pageItem.label == "placeholder2")
{
pageItem.contents = app.scriptArgs.getValue("arg2");
}
if (pageItem.constructor.name == "TextFrame" && pageItem.label == "placeholder3")
{
pageItem.contents = app.scriptArgs.getValue("arg3");
}
}
}
function main(){
var myTemplateFile = new File("/c/ServerFiles/template.indt");
var myFile = new File("/c/ServerFiles/brochure.pdf");
var doc = app.open(myTemplateFile);
// get scriptArgs and update
LoadDataIntoTemplate(doc);
// Export as PDF
ExportAsPDF(myFile);
doc.close();
alert("PDF Exported");
}
main();