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.
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.
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.
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.
Copy link to clipboard
Copied
You're missing a set of closing curly brackets.
Copy link to clipboard
Copied
Where? I copied it exactly from the page.
Copy link to clipboard
Copied
At the very end.
Copy link to clipboard
Copied
There is a closing curly bracket. I even added another one after that and still get the syntax error.
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>
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
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.
Copy link to clipboard
Copied
I'm not sure. It depends on what the profile is doing, I think.
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.
Copy link to clipboard
Copied
Thanks
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");
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);
// ...
Copy link to clipboard
Copied
Thanks Buddy. I appreciate it the code. I will take a look at it.
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("-----------------------------------------");
}
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.
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...
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).
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.