How to find the OC COSName in a PDPage belong to which Optional Content Group?

135 Views Asked by At

I have implemented functionality to allow user to draw a cloud shape on a pdf, using the PDPageContentStream class's curve methods.And, I am drawing each of this cloud on a separate layer(OCG). Now I want to implement functionality to delete this markup. I am using the following code to get the PDPage contents:

PDPage page = (PDPage)doc.getDocumentCatalog().getPages().get(pageNum);
PDFStreamParser parser = new PDFStreamParser(page);
parser.parse();
java.util.Collection tokens = parser.getTokens();

For the markup, I first get a COSName{OC} token, and then I get the BDC command. So, all I need to do is to detect, that to which layer does this OC tag belong. And then I will know that the following marked sequence belongs the layer.Hence, I can delete all the tokens between BDC and EMC to delete the markup. But how do I know, that to which layer does this OC tag belong?

0

There are 0 best solutions below