[javascript FR] annotation get/set of OCG (Layer) and Blend Mode  SOLVED

Please post any ideas or requests for new features here for the End User Version of PDF-XChange (printer Drivers)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Mathew
User
Posts: 765
Joined: Thu Jun 19, 2014 7:30 pm

[javascript FR] annotation get/set of OCG (Layer) and Blend Mode

Post by Mathew »

A couple of annotation properties that are conspicuously absent in the javascript API are:
  1. the optional content group (layer) that an annotation is assigned to; and
  2. the blend mode assigned to the annotation
Both of these are quite important in how markups are shown, so being able to get and set them would be very helpful for javascript tools working on annotations. The OCGs can be viewed and edited (but not added to) at a document level, so IMO it's surprising that javascript is blind to them for markup.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12519
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript FR] annotation get/set of OCG (Layer) and Blend Mode

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for the suggestions.
I could be wrong, but I vaguely recall hearing that OCG's are not able to be handled by JS due to some unique bits of their use/implementation, but perhaps I misremembered or it has changed.
Blend mode on the other hand I cannot say I have ever heard anything against.

I have forwarded both requests to the Dev team to see what comes of them.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 765
Joined: Thu Jun 19, 2014 7:30 pm

Re: [javascript FR] annotation get/set of OCG (Layer) and Blend Mode

Post by Mathew »

Daniel - PDF-XChange wrote: Thu Sep 11, 2025 9:31 pm I could be wrong, but I vaguely recall hearing that OCG's are not able to be handled by JS due to some unique bits of their use/implementation, but perhaps I misremembered or it has changed.
Thanks Daniel. Looks like both are part of the annotation dictionary as of ISO 32000-2:
image.png
image(1).png
image(2).png
Blend Mode is much more recent though.
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12519
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript FR] annotation get/set of OCG (Layer) and Blend Mode

Post by Daniel - PDF-XChange »

Hello, Mathew

That is good to hear, hopefully it translates to good news from the Dev team!

RT#7633: JS-FR: Annot OCG and Blend mode access 8)

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3602
Joined: Thu Jul 08, 2004 10:36 pm

Re: [javascript FR] annotation get/set of OCG (Layer) and Blend Mode  SOLVED

Post by Ivan - Tracker Software »

In version 10.7.3, a property blendMode has been added for the annot object.
It is a read/write property.

Example of setting Multiply blend mode for all annots on the first page:

Code: Select all

var annots = getAnnots(0);
for (var i = 0; i < annots.length; ++i)
  annots[i].blendMode = blendModes.multiply;
or the same, but in a "modern way":

Code: Select all

getAnnots(0).forEach((a) => a.blendMode = blendModes.multiply);
Global object blendModes contains constants for all possible blend modes. To get the list, just run

Code: Select all

blendModes.toSource();
HTH
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3602
Joined: Thu Jul 08, 2004 10:36 pm

Re: [javascript FR] annotation get/set of OCG (Layer) and Blend Mode

Post by Ivan - Tracker Software »

Also, added read/write property OC (optional content).
It allows assigning an OCG (layer) to the annotation, or getting the assigned OCG.
If the annotation has no OCG, this property will have a value null.
To set a value to this property, a null or OCG object should be used.

Unfortunately, due to the limitations of the JS model, if an annotation object has an associated OCMD, this property will have the value null as the OCMD is not presented in the JS model.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.