Get the layers/OCG list and show/hide them

A forum for questions or concerns related to the PDF-XChange Core API SDK

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

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Get the layers/OCG list and show/hide them

Post by Max SAG »

Hi,

Using the PDF-XChange Core API SDK, I'm trying to get the list of the layers of the PDF document to hide and show them calling DrawToDevice. I already saw this topic: Show/hide layers/OCG by name
If I understood correctly they are called "Optional Content Groups (OCG)".

Get the layers
The list of layers seems to be available using IPXC_OCMD.OCG but I can't find a way to create or get this object.

Set the visiblity
As mentioned in the other topic, the visibility can be set using IPXC_OCContext.SetOCState, but I don't know what is the pOCObj parameter, maybe the IPXC_OCMD?

I tried to find examples in the GitHub samples without luck.

Thank you for your help,

Max
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Get the layers/OCG list and show/hide them

Post by Sasha - Tracker Dev Team »

Hello Max,

Right now, there is no direct way of working with OCGs/OCMDs directly via the Core API SDK.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: Get the layers/OCG list and show/hide them

Post by Max SAG »

Hi Sasha,

Thank you for your answer. Which of your SDK can interact with OCGs/OCMDs?

Best regards,

Maxime
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Get the layers/OCG list and show/hide them

Post by Sasha - Tracker Dev Team »

Hello Maxime,

For now, there is no full functionality on either level - though you can always do everything manually via the PDF Structure (as you would have done in the Viewer SDK) though this requires deep knowledge of the PDF structure and specification. Also, you can do operations available via the JS.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: Get the layers/OCG list and show/hide them

Post by Max SAG »

Alex,

OK. I guess that IPXV_Inst::ExecuteJS is only available using the Editor API SDK?

Best regards,

Max
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Get the layers/OCG list and show/hide them

Post by Sasha - Tracker Dev Team »

Hello Max,

Yes, Editor SDK it is.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: Get the layers/OCG list and show/hide them

Post by Max SAG »

Hi Alex,

OK.
One more question as I try to estimate the work to do before beginning the development, if we manage to identify the layer in the PDF structure using the Core API SDK, will it be possible to use the IPXC_OCContext.SetOCState method to hide/show them? Even after checking the documentation, I still don't understand what IPXS_PDFVariant* pOCObj stands for.

Best regards,

Max
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Get the layers/OCG list and show/hide them

Post by Sasha - Tracker Dev Team »

Hello Max,

It stands for the PDF Structure Dictionary of the correspondent OCG or OCMD. You can get the Name entry to see the OCG name for comparison to do this use the Dict_GetString method of the IPXS_PDFVariant.
For more information, you will have to read the Optional Content chapter of the PDF Reference (in the latest one it's the 8.11. chapter) that you can find under the Graphics chapter.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: Get the layers/OCG list and show/hide them

Post by Max SAG »

Hi Alex,

OK, thank you for your explanation.

Have a good day,
Max
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Get the layers/OCG list and show/hide them

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply