5 Replies Latest reply on Feb 12, 2010 12:04 AM by Peter Bossens

    Activate a profile in Live Preflight - JS

    Peter Bossens

       

      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

        • 1. Re: Activate a profile in Live Preflight - JS
          Shonkyin Level 3

          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

          • 2. Re: Activate a profile in Live Preflight - JS
            Shonkyin Level 3

            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

            • 3. Re: Activate a profile in Live Preflight - JS
              Peter Bossens Level 1

              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

              • 4. Re: Activate a profile in Live Preflight - JS
                Shonkyin Level 3

                 

                var myDocument=app.activeDocument;

                app.preflightOptions.preflightOff = false;

                myDocument.preflightOptions.preflightWorkingProfile= 'TestProflie'

                Shonky

                • 5. Re: Activate a profile in Live Preflight - JS
                  Peter Bossens Level 1

                  Shonky,

                   

                  Yes, perfect, thanks a lot!

                   

                  Peter