On 8/6/2014 10:01 AM, Pichtchikov, Alexandre wrote:
I am merging tagged pdf with untagged pdf. I am getting exception when I close Document object:It looks like NullPointerException(PdfCopy.java:890) is generated at this line:NullPointerException(PdfCopy.java:890) Call stack com.itextpdf.text.pdf.PdfCopy.fixTaggedStructure(PdfCopy.java:890) com.itextpdf.text.pdf.PdfCopy.flushTaggedObjects(PdfCopy.java:866) com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:855) com.itextpdf.text.Document.close(Document.java:416) ...... Code: PdfReader basePDF = new PdfReader( byteArray );PdfReader legendInformation = new PdfReader( legendsStaticPDFs.get( language ) );boolean isBasePDFTagged = basePDF.isTagged(); boolean islegendInformationTagged = legendInformation.isTagged(); // Representation of the resultant, merged, PDF Document document = new Document( basePDF.getPageSize( 1 ) );// Wrap the target PDF in something concrete to facilitate adding pagesByteArrayOutputStream outputStreamNew = new ByteArrayOutputStream(); PdfCopy newPDF = new PdfCopy( document, outputStreamNew ); newPDF.setTagged(); // Set the PDF language (Accessibility standards) newPDF.getExtraCatalog().put(PdfName.LANG, new PdfString( language.locale.getLanguage() ) ); // Set the PDF document title (Accessibility standards) newPDF.getInfo().put(PdfName.TITLE, new PdfString( messageSourceAccessor.getMessage( "statement.pdf.title." + language.locale.getLanguage() ) ) ); document.open(); appendPDF( newPDF, basePDF ); //appendPDF( newPDF, legendInformation ); document.close();I checked this _Merging Tagged PDF without ruining the tags_ <http://stackoverflow.com/questions/19839445/merging-tagged-pdf-without-ruining-the-tags>, and have found that it should be fixed, but it still exist at least in iText 5.5.2 I used. Is it any work around? Could PageName.PG be set manually? Thanks in advance.
HashMap<Integer, PdfIndirectReference> numTree = structureTreeRoot.getNumTree();//iText 5.5.2;PdfCopy.java:890
structureTreeRoot can be null in case the method getImportedPage(PdfReader, int, boolean) was used without keeping tagged structure (which would be wrong use of iText). Unfortunately, this code is hidden in your appendPDF() method so we can't check if you're doing something wrong or if there's really a problem inside iText.
The issue with a PG key has been fixed in iText 5.5.0.
------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________ 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
