Hi,

Am 14.08.2013 11:17, schrieb Axel Rose:
Hello all,

has anybody a working solution or a guide for me how to achieve this:

Given a COSDictionary object how would I get a recursive text dump of
all its subobject?

I tried something like:

   PDDocument doc = PDDocument.load(file);
   PDDocumentCatalog catalog = doc.getDocumentCatalog();
   List<PDPage> allPages = catalog.getAllPages();
   for (PDPage page : allPages) {
     COSDictionary pageDict = page.getCOSDictionary();
     for (Entry<COSName, COSBase> entry : pageDict.entrySet()) {
       if (value instanceof COSArray)
         // process array
       else if (value instanceof COSString)
         // process String
       else if (value instanceof COSObject)
         // stuck
     }
   }

I'm stuck how to recurse into the COSObject.
Try something like this to get the encapsulated object:

COSBase baseObject = ((COSObject)value).getObject();


pageDict.toString() gives me some overview:

COSDictionary{
   (COSName{Annots}:COSArray{[COSObject{19, 0}, COSObject{20, 0}]})

but also doesn't go deeper into the "Annots" object.


Thanks for your help
Do you need the information for a further process or are you just interested to
see those information for debugging purposes or something similar? Maybe you
should try the PDFDebugger.


Axel

BR
Andreas Lehmkühler

Reply via email to