Skip to main content
Inspiring
March 9, 2017
Answered

JavaScript or AppleScript - how to map 1 colour in pdf

  • March 9, 2017
  • 2 replies
  • 1922 views

Hi all

I am trying to map one specific colour to white in a pdf, and I can't for the life of me find anything that I can use. From what iv'e read

it seems that javascript is the better option for manipulating acrobat dc, but I have zero experience with it, applescript, quite a bit, so

I was thinking id just call the javascript in my apple script.

The colour I am trying to map is Keyline and I am wanting to convert to White, the colour keyline is made up from C0 M100 Y0 K20

and converted to spot.

Could some one please give me some infor or a snippet of javascript or applescript that I can add to the rest of my code please.

thankyou.

tell application "Adobe Acrobat"

    activate

    tell active doc

        repeat with i from 1 to count of pages

            tell page i

                set {L, T, R, B} to media box

                 set crop box to {L + 5 * 2.834645, T - 5 * 2.834645, R - 5 * 2.834645, B + 40.2 * 2.834645} -- points to mm conversion

                 --close active doc saving yes

                end tell

           end repeat

       end tell

end tell

This topic has been closed for replies.
Correct answer try67

I have found through a lot of searching that I can actually run a preflight profile, great, which means I can now map my colour to white, the code attached tells me "true" which indicates to me it has seen the profile, but the profile does not run, can some one please suggest a possible reason or answer as to why it wont execute?

cheers

kev

tell application "Adobe Acrobat"

    do script "var oProfile = Preflight.getProfileByName('Map color with specified color values');

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

}"

end tell


You're doing nothing but retrieve the Preflight Profile... Now you need to actually execute it, using the preflight method of the Document object, like this:

this.preflight(oProfile);

2 replies

JR Boulay
Community Expert
Community Expert
March 9, 2017

Hi.

Answer is in the Acrobat's preflight. There is a fixup that can do that, but since I don't use Acrobat in English I can't help you furthermore.

This (French) topic and Google Translate may help you: http://abracadabrapdf.net/forum/index.php/topic,3193.0.html

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
March 9, 2017

JR_Boulay 

Thanks for the reply, I have been using the map to colours function in Acrobat's preflight set up, which works great, even tried to implement regex into my apple script, but had no success, as I no less about regex than I do about JavaScript.

Inspiring
March 13, 2017

so instead of trying to map the colour, how would I go about having its layer not print?, is this do-able?

cheers

Legend
March 9, 2017

There is no JavaScript or ApleScript API to edit page contents or colours.

Karl Heinz  Kremer
Community Expert
Community Expert
March 9, 2017

That is correct in general, but in this case - mapping a spot color to some other color - there is actually functionality in the JavaScript API that claims that it can do this. However, it's badly documented and my experiments a few years ago where not too promising. See here for more information:

Acrobat DC SDK Documentation - Doc.colorConvertPage()

I can convert pages (and therefore a document) to a given color space (e.g. convert to grayscale), but never was able to convert one spot color to a different color.