-
Notifications
You must be signed in to change notification settings - Fork 0
/
preflight-with-profile.jsx
78 lines (66 loc) · 2.99 KB
/
preflight-with-profile.jsx
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* USAGE
* Run from the command line using sampleclient.exe that comes with InDesign Server
* Make sure InDesign Server is running at the address and port you spcifiy in the -host parameter
*
* > sampleclient -host localhost:18383 <file path>\\preflight-with-profile.jsx indesignFilePath="<file path>\\<filename>.indd|idml"
*
* Please note there are some hard coded file paths in the script below that you'll need to change.
*
* Parameters
* indesignFilePath - full file path and name of InDesign file to test
*
* NOTES
* Docs for ExtendScript: https://extendscript.docsforadobe.dev/
* ExtendScript Debugger Extension for VS Code (https://marketplace.visualstudio.com/items?itemName=Adobe.extendscript-debug)
* Install ExtendScript Toolkit and edit the script (and debug it directly with InDesign Server - sort of) (https://github.com/Adobe-CEP/CEP-Resources/tree/master/ExtendScript-Toolkit)
*
* DESCRIPTION
* 1. Opens the passed InDesign file
* 2. Loads the profile at c:\\temp\\ids\\sample-profile.idpp
* 3. Attempts to preflight the InDesign file using the given profile
* 4. Writes the preflight report file to disk at c:\\temp\\ids\\preflight-report.txt
*
* And it emits a lot of stuff to the console as it goes.
*
*/
app.consoleout("Init IDS test");
if (app.scriptArgs.isDefined("indesignFilePath")) {
var indesignFilePath = app.scriptArgs.getValue("indesignFilePath");
// TODO: replace these
var profileFilePath = "c:\\temp\\sample-profile.idpp";
var preflightReportFilePath = "c:\\temp\\preflight-report.txt";
app.consoleout("Opening " + indesignFilePath);
var indesignFile = app.open(File(indesignFilePath));
app.consoleout("Opened " + indesignFilePath);
app.consoleout("Loading profile " + profileFilePath);
var profile = app.loadPreflightProfile(File(profileFilePath));
app.consoleout("Profile loaded");
if (profile != null) {
app.consoleout("Profile is not null");
app.consoleout("Preflighting");
var process = app.preflightProcesses.add(indesignFile, profile);
app.consoleout("Wait for process");
// NOTE: IDS sometimes says "No errors yet; still looking". Often with .idml files.
// If you don't put waitForProcess() twice process.processResults will return "None" and you won't get a preflight report
process.waitForProcess();
process.waitForProcess();
app.consoleout("Process results");
results = process.processResults;
app.consoleout("Results: " + results);
if (results != "None") {
process.saveReport(File(preflightReportFilePath));
} else {
app.consoleout("No preflight results");
}
process.remove();
app.consoleout("Process removed");
app.consoleout("End preflight");
} else {
app.consoleout("Could not load preflight profile");
}
} else {
app.consoleout("Could not find indesignFilePath parameter");
}
app.consoleout("End ids test");
"Finished";