Copy link to clipboard
Copied
I would like to activate an existing Live Preflight profile for the active document.
The code I have is:
var myDocument=app.activeDocument;
var ProfileName = "TestProfile";
process.waitForProcess();
results = process.processResults;
But I get an error that the document is undefined, why?
Thanks,
Peter
var myDocument=app.activeDocument;
app.preflightOptions.preflightOff = false;
myDocument.preflightOptions.preflightWorkingProfile= 'TestProflie'
Copy link to clipboard
Copied
Hi Peter,
You can generate the report if error found. Please see below code:
var myDocument=app.activeDocument;
var profile = app.preflightProfiles.add();
profile.name = "Test";
profile.description = "Test description";
const RULE_NAME = "ADBE_PageSizeOrientation";
var rule = profile.preflightProfileRules.add(RULE_NAME);
//Requires the page size to be 8.5 in x 11in (Letter Size)
//
//enters a value for tolerance
rule.ruleDataObjects.add("tolerance", RuleDataType.realDataType, 0.01);
//Sets the width to the point equivalent of 8.5 inches
rule.ruleDataObjects.add("width", RuleDataType.realDataType, 612);
// Sets the width to the point equivalent of 11 inches
rule.ruleDataObjects.add("height", RuleDataType.realDataType, 792);
//true = ignore orientation is checked
rule.ruleDataObjects.add("ignore_orientation", RuleDataType.booleanDataType, true);
//set the rule to return an error
rule.flag = PreflightRuleFlag.returnAsError;
//Process the doc with the rule
var process = app.preflightProcesses.add(myDocument, profile);
process.waitForProcess();
results = process.processResults;
//If Errors were found
if (results != 'None')
{
//Export the file to PDF
//The “true” value selects to open the file after export.
process.saveReport(File("~/Desktop/preflight.pdf"), true);
}
Copy link to clipboard
Copied
And here is your code:
var myDocument=app.activeDocument;
var process = app.preflightProcesses.add(myDocument, app.preflightProfiles.item('TestProfile'));
process.waitForProcess();
results = process.processResults;
if (results != 'None')
{
//Export the file to PDF
//The “true” value selects to open the file after export.
process.saveReport(File("~/Desktop/preflight.pdf"), true);
}
I hope it will help you.
Shonky
Copy link to clipboard
Copied
Shonkyin,
Yes, that works!
Just one more thing: the script uses the right profile to create the report, but afterwards, another ("[Basic] (working)") profile is visible in the palette.
Is there a way to activate a specific profile in InDesign's Live Preflight palette?
Thanks,
Peter
Copy link to clipboard
Copied
var myDocument=app.activeDocument;
app.preflightOptions.preflightOff = false;
myDocument.preflightOptions.preflightWorkingProfile= 'TestProflie'
Copy link to clipboard
Copied
Shonky,
Yes, perfect, thanks a lot!
Peter
Find more inspiration, events, and resources on the new Adobe Community
Explore Now