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

JavaScript or AppleScript - how to map 1 colour in pdf

Engaged ,
Mar 08, 2017 Mar 08, 2017

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

TOPICS
Acrobat SDK and JavaScript
1.6K
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

correct answers 1 Correct answer

Community Expert , Mar 20, 2017 Mar 20, 2017

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

Translate
LEGEND ,
Mar 08, 2017 Mar 08, 2017

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

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 ,
Mar 09, 2017 Mar 09, 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.

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 ,
Mar 09, 2017 Mar 09, 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
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
Engaged ,
Mar 09, 2017 Mar 09, 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.

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
Engaged ,
Mar 13, 2017 Mar 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

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
Engaged ,
Mar 13, 2017 Mar 13, 2017

getting somwhere (well only a little bit)

managed to figure out how to hide the layer, but when acrobat closes and saves via the rest of my code it doesn't save the  state, which is having the layer hidden.

   tell application "Adobe Acrobat"
   do script "var ocgs = this.getOCGs();

for (var i in ocgs) {

if (ocgs.name == ('Keyline'))

ocgs.state = false;

else ocgs.state = true;

}"

   end tell
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
Engaged ,
Mar 20, 2017 Mar 20, 2017

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

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 ,
Mar 20, 2017 Mar 20, 2017

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

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
Engaged ,
Mar 20, 2017 Mar 20, 2017

thanks for the reply try67, my javascript knowledge is extremely little, could you show me how ot execute please, I have had a look in the AcrobatDC_js_api_reference, but I just get myself very confused.

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 ,
Mar 20, 2017 Mar 20, 2017

I edited my previous reply with the code that you need to use to do it. I can't help you with converting it to AS code, 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
Engaged ,
Mar 20, 2017 Mar 20, 2017
LATEST

ABSOLUTELY EXCELLENT, really appreciate it

here's the final, to simple

tell application "Adobe Acrobat"

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

this.preflight(oProfile);

"

                end tell

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