Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Activate a profile in Live Preflight - JS

Explorer ,
Feb 11, 2010 Feb 11, 2010

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";

var process = app.preflightProcesses.add(myDocument, ProfileName);

process.waitForProcess();

results = process.processResults;

But I get an error that the document is undefined, why?

Thanks,

Peter

TOPICS
Scripting
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Feb 11, 2010 Feb 11, 2010

var myDocument=app.activeDocument;

app.preflightOptions.preflightOff = false;

myDocument.preflightOptions.preflightWorkingProfile= 'TestProflie'

Shonky

Translate
Engaged ,
Feb 11, 2010 Feb 11, 2010

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);

}

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 11, 2010 Feb 11, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 11, 2010 Feb 11, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 11, 2010 Feb 11, 2010

var myDocument=app.activeDocument;

app.preflightOptions.preflightOff = false;

myDocument.preflightOptions.preflightWorkingProfile= 'TestProflie'

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 12, 2010 Feb 12, 2010
LATEST

Shonky,

Yes, perfect, thanks a lot!

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines