Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DDCD410503 for ; Thu, 15 Aug 2013 08:10:13 +0000 (UTC) Received: (qmail 47199 invoked by uid 500); 15 Aug 2013 08:10:13 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 47143 invoked by uid 500); 15 Aug 2013 08:10:13 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 47130 invoked by uid 99); 15 Aug 2013 08:10:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Aug 2013 08:10:13 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [81.169.146.160] (HELO mo-p00-ob.rzone.de) (81.169.146.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Aug 2013 08:10:05 +0000 X-RZG-AUTH: :LWIAZ0WpaN8UY5o8XRz0jOyrHsdEC+nAE10OdySrgHL6ku8V1wBegXvWJ4CT X-RZG-CLASS-ID: mo00 Received: from [192.168.1.8] (dslb-088-077-240-231.pools.arcor-ip.net [88.77.240.231]) by smtp.strato.de (RZmta 31.39 DYNA|AUTH) with ESMTPA id C0447dp7F88JoT for ; Thu, 15 Aug 2013 10:09:25 +0200 (CEST) Message-ID: <520C8CB4.20500@lehmi.de> Date: Thu, 15 Aug 2013 10:09:24 +0200 From: Andreas Lehmkuehler User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: users@pdfbox.apache.org Subject: Re: dump COSDictionary recursively References: <4767C3E5-B301-417D-8F81-CE37E692127F@googlemail.com> In-Reply-To: <4767C3E5-B301-417D-8F81-CE37E692127F@googlemail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org 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 allPages = catalog.getAllPages(); > for (PDPage page : allPages) { > COSDictionary pageDict = page.getCOSDictionary(); > for (Entry 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