Copy link to clipboard
Copied
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
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);
Copy link to clipboard
Copied
There is no JavaScript or ApleScript API to edit page contents or colours.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Thanks for the reply, well, if JavaScript coder can't do it then I have very little chance, shame really as it seems so basic in theory.
Copy link to clipboard
Copied
so instead of trying to map the colour, how would I go about having its layer not print?, is this do-able?
cheers
Copy link to clipboard
Copied
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 |
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now