pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Axel Rose <axel.roesl...@googlemail.com>
Subject dump COSDictionary recursively
Date Wed, 14 Aug 2013 09:17:56 GMT
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.

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

Axel


Mime
View raw message