How do I delete an OCG/layer completely from PDF?

478 views
Skip to first unread message

Support

unread,
Jan 15, 2010, 6:34:23 PM1/15/10
to PDFTron PDFNet SDK
Q: i want to delete a OCG (layer). But if I do that, the elements from
the
ocg gets merged with the default content.

So, how do I delete a OCG completely?

------------
A: The problem is that in PDF layers are always part of PDF content.
Actually layers are implemented as marked content (tags) which
associate parts of PDF content stream with a dictionary describing the
layer (i.e. OCG dictionary). It seems that what you are looking for is
a way to remove any parts of PDF page which are associated with a
given OCG group.

For example of how to remove specific elements from a PDF page please
see ElementEdit sample (http://www.pdftron.com/pdfnet/
samplecode.html#ElementEdit). The only remaining issue is:

how to decide whether an element belongs to a specific layer?

The Element interface offer the following relevant methods:

int GetStructMCID();
bool IsOCVisible();

GetStructMCID should allow you to find the OCG for the given element
(if any) from 'Properties' dictionary stored in page.GetResourcesDict
(). Even simpler approach would be to configure the layer visibility
using high-level PDFNet API-s and then use element.IsOCVisible().

Reply all
Reply to author
Forward
0 new messages