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

Convert to CMYK only (SWOP)

New Here ,
Feb 23, 2018 Feb 23, 2018

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
1.7K
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
Community Expert ,
Feb 24, 2018 Feb 24, 2018

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.

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
New Here ,
Feb 24, 2018 Feb 24, 2018

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

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
Community Expert ,
Feb 24, 2018 Feb 24, 2018

You're missing a set of closing curly brackets.

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
New Here ,
Feb 24, 2018 Feb 24, 2018

Where?  I copied it exactly from the page.

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
Community Expert ,
Feb 24, 2018 Feb 24, 2018

At the very end.

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
New Here ,
Feb 24, 2018 Feb 24, 2018

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

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
Community Expert ,
Feb 24, 2018 Feb 24, 2018

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>

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
New Here ,
Feb 24, 2018 Feb 24, 2018

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

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
New Here ,
Feb 25, 2018 Feb 25, 2018

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.

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
Community Expert ,
Feb 26, 2018 Feb 26, 2018

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

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
Community Expert ,
Feb 26, 2018 Feb 26, 2018

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.

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
New Here ,
Feb 26, 2018 Feb 26, 2018

Thanks

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
New Here ,
Feb 26, 2018 Feb 26, 2018

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

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
Community Expert ,
Feb 26, 2018 Feb 26, 2018

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

// ...

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
New Here ,
Feb 26, 2018 Feb 26, 2018

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

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
New Here ,
Feb 26, 2018 Feb 26, 2018

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

}

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
Community Expert ,
Feb 26, 2018 Feb 26, 2018

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.

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
Community Expert ,
Feb 26, 2018 Feb 26, 2018

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

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
Community Expert ,
Feb 26, 2018 Feb 26, 2018

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

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
New Here ,
Feb 26, 2018 Feb 26, 2018
LATEST

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

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