Re: method PdfCopy.fixTaggedStructure throws NullPointerException

"Pichtchikov, Alexandre" <[email protected]>
Newsgroups gmane.comp.java.lib.itext.general
Message-ID <A30CA919C96A5544977357131E6583EBA4700EDB@MSGMMKCCRB2WIN.DMN1.FMR.COM>
Thanks a lot for looking into this.
I tied to add third parameter to getImportedPage so it looks like this:

 target.addPage( target.getImportedPage( source, i, true ) );


I am getting the following exception now:

Exception thrown
                BadPdfFormatException: No StructTreeRoot found, this probably isn't a tagged PDF document!(PdfStructTreeController.java:69)
Call stack
                com.itextpdf.text.pdf.PdfStructTreeController.<init>(PdfStructTreeController.java:69)
                com.itextpdf.text.pdf.PdfCopy.getImportedPage(PdfCopy.java:263)
                com.fmr.fic.ai.service.PDFGenerationServicejClassImpl.appendPDF(PDFGenerationServicejClassImpl.java:877)
                com.fmr.fic.ai.service.PDFGenerationServicejClassImpl.generateStatementsFromXML(PDFGenerationServicejClassImpl.java:588)
                com.fmr.fic.ai.service.PDFGenerationServicejClassImpl.generateStatement(PDFGenerationServicejClassImpl.java:486)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                java.lang.reflect.Method.invoke(Method.java:597)
                org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
                (124 more)

I checked PdfStructTreeController code, and have found that exception is thown by this line of code:

if (!writer.isTagged())
            throw new BadPdfFormatException(MessageLocalization.getComposedMessage("no.structtreeroot.found"));

In my case, writer is my PdfCopy object, and I used newPDF.setTagged(). Is something missing?

Thanks,
Alex

From: iText mailing list [mailto:[email protected]]
Sent: Thursday, August 07, 2014 2:22 PM
To: [email protected]
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

On 8/7/2014 10:39 AM, Pichtchikov, Alexandre wrote:
target.addPage( target.getImportedPage( source, i ) );

This line is wrong, you should add the boolean value that tells iText to preserve the structure.

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds

_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.