Get Annotations from OCG with JavaScript

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
benep
User
Posts: 12
Joined: Thu Dec 08, 2022 7:14 am

Get Annotations from OCG with JavaScript

Post by benep »

Hello,

is it possible to get the contents of an OCG via JavaScript, specifically annotations?
After selecting an annotation it is possible to put it in a layer / an OCG, however I can't find any relation between OCG and its contents that I could use within a script.

thanks in advance
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Get Annotations from OCG with JavaScript

Post by Tracker Supp-Stefan »

Hello benep,

an object inside a PDF file may belong to more than one OCG - so OCGs in their design are complicated.
And I've also spent some time looking at the JS documentation and indeed it does not seem like there's a way for you to get a list of objects that belong to a specific OCG. There does not seem to be methods to check for a specific annotation whether it is part of an OCG either (so e.g. you could iterate through all the annotations and check which are on your layer) .

Kind regards,
Stefan
Post Reply