Convert to CMYK only (SWOP)

Feb 23, 2018

Copy link to clipboard

Copied

Im learning Javascript to help me with my pre-press automation.  Can someone tell me how to run the Preflight "Convert to CMYK only (SWOP)" with javascript? 

Thank you.

TOPICS
Acrobat SDK and JavaScript

Views

317

Likes

Translate

Translate

Report

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

Convert to CMYK only (SWOP)

Feb 23, 2018

Copy link to clipboard

Copied

Im learning Javascript to help me with my pre-press automation.  Can someone tell me how to run the Preflight "Convert to CMYK only (SWOP)" with javascript? 

Thank you.

TOPICS
Acrobat SDK and JavaScript

Views

318

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 23, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

The Document object has a method called preflight, which can execute any Preflight Profile. Read its documentation and see the example provided with it. If you still have questions after doing that, post back.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

That much I found out before the post from this link: https://help.adobe.com/livedocs/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp....

But when I run the example in that page I get a syntax error.  Below is the example.

var oProfile = Preflight.getProfileByName("Magazine Ads")

if( oProfile != undefined )

{

var oThermometer = app.thermometer;

var myPreflightResult = this.preflight( oProfile, false, oThermometer);

if( myPreflightResult.numErrors > 0 ) {

console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");

} else {

console.println( "Preflight found no Errors.");

}

See snapshot.

Screen Shot 2018-02-24 at 11.31.00 AM.jpg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

You're missing a set of closing curly brackets.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

Where?  I copied it exactly from the page.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

At the very end.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

There is a closing curly bracket.  I even added another one after that and still get the syntax error.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 24, 2018

Copy link to clipboard

Copied

Are you selecting the full code (with the mouse/keyboard) before running it?

On 24 February 2018 at 18:09, ericr14066074 <forums_noreply@adobe.com>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 1
Feb 24, 2018

Copy link to clipboard

Copied

As I said in my first post im just learning.  Didnt know I had to highlight the code and then run it.  Now i know   Thanks.

What I was doing before was opening acrobat with a document open, hitting command J pasting the code into it and moving the cursor to the bottom and then hitting FN enter to execute it.

Thanks for the tips

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2018 0
Feb 25, 2018

Copy link to clipboard

Copied

Can you run these preflight profiles without it saving the file.  My intention is to run the profile and then create another document with another name which I already figured out.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 25, 2018 0
Feb 26, 2018

Copy link to clipboard

Copied

I'm not sure. It depends on what the profile is doing, I think.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 0
Feb 26, 2018

Copy link to clipboard

Copied

You cannot run a profile that applies changes without Preflight saving the file. When you run the profile interactively, Acrobat will prompt you for the new file name, when you use the JavaScript interface, it will save automatically back to the original file. What I do when I want to save to a different file name is to save the file first and then run the preflight profile.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 1
Feb 26, 2018

Copy link to clipboard

Copied

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 0
Feb 26, 2018

Copy link to clipboard

Copied

So your saying in my script I should have the save file first then run the preflight?  See my script below.

var oProfile = Preflight.getProfileByName("Convert fonts to outlines")

if( oProfile != undefined )

{

var oThermometer = app.thermometer;

var myPreflightResult = this.preflight( oProfile, false, oThermometer);

if( myPreflightResult.numErrors > 0 ) {

console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");

}

else {

console.println( "Preflight found no Errors.");

}

}

var newFilename = this.documentFileName.replace(".pdf", "");

this.extractPages(0, 0, newFilename + "-PREFLIGHT.pdf");

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 0
Feb 26, 2018

Copy link to clipboard

Copied

Doc.extractPages() will not work, because it creates a new document. You will need to save your current document first using Doc.saveAs() (Acrobat DC SDK Documentation )

Your code will look something like this:

// ...

this.saveAs("/some/file/name.pdf");

this.preflight(oProfile, false, oThermometer);

// ...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 1
Feb 26, 2018

Copy link to clipboard

Copied

Thanks Buddy.  I appreciate it the code.  I will take a look at it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 0
Feb 26, 2018

Copy link to clipboard

Copied

https://forums.adobe.com/people/Karl+Heinz+Kremer  wrote

Doc.extractPages() will not work, because it creates a new document. You will need to save your current document first using Doc.saveAs() (Acrobat DC SDK Documentation )

Your code will look something like this:

// ... this.saveAs("/some/file/name.pdf"); this.preflight(oProfile, false, oThermometer); // ...

This worked perfect.  Now when I try to move my javascript over to another computer its not working.  I think my other computer somehow doesnt see the preflight profiles.  I say that because when I run the script below on my first computer which everything is working fine I get the preflight profile name and description.  But when I run it on my other computer it does nothing and I get an UNDEFINED message.

var oProfile = Preflight.getProfileByName("Convert to CMYK only (SWOP)");

if( oProfile != undefined) {

   console.println("-----------------------------------------");

   console.println("Name: " + oProfile.name);

   console.println("Comment: " + oProfile.description);

   console.println("HasFixups: " + oProfile.hasFixups);

   console.println("HasChecks: " + oProfile.hasChecks);

   console.println("-----------------------------------------");

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 0
Feb 26, 2018

Copy link to clipboard

Copied

Is the second computer running Adobe Acrobat Standard, or a much older version of Adobe Acrobat? Preflight is only available in Acrobat Pro, and when you look at the JavaScript API documentation, the JavaScript preflight support was introduced with Acrobat 9. This means that if you have e.g. Adobe Acrobat DC Standard, or Adobe Acrobat 8 Pro, this will not work.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 1
Feb 26, 2018

Copy link to clipboard

Copied

"undefined" means the script ended without errors or returning a value. I would add this line to the end of the code:

else console.println("Error! Can't find the Preflight Profile.");

If you see this text appears in the console after running the code then it means the profile doesn't exist. You can create it, though...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 1
Feb 26, 2018

Copy link to clipboard

Copied

You also need to copy the preflight profile from your computer to the second computer if that profile is not yet avaiable. You can do that from within the Preflight dialog by exporting on one system and importing on the second (these functions are in the Preflight dialog's menu).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 1
Feb 26, 2018

Copy link to clipboard

Copied

https://forums.adobe.com/people/Karl+Heinz+Kremer  wrote

You also need to copy the preflight profile from your computer to the second computer if that profile is not yet avaiable. You can do that from within the Preflight dialog by exporting on one system and importing on the second (these functions are in the Preflight dialog's menu).

Nevermind.  I figured it out. Both my computers run Acrobat pro.  Same versions.  The problem was that I had to go to edit>preflight and change the profile dropdown in the middle to read "Acrobat Pro DC 2015 Profiles".  Then it worked with no issue.  Is there a way in javascript to change that dropdown or to make sure its always reading from those profiles and not the other ones or the custom ones.

Forgot to add the snapshot.

Screen-Shot-2018-02-26-at-3.43.15-PM.jpg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 26, 2018 0