Quantcast

method PdfCopy.fixTaggedStructure throws NullPointerException

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
I am merging tagged pdf with untagged pdf. I am getting exception when I close Document object:
    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 pages
        ByteArrayOutputStream 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, 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.
 
 

------------------------------------------------------------------------------
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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

info-2
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:
    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 pages
        ByteArrayOutputStream 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, 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.
It looks like NullPointerException(PdfCopy.java:890) is generated at this line:

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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre

Hello,

Thanks a lot for the replay.

Yes, my bad, I should include appendPDF method from the beginning.

Here is the code :
     private static final void appendPDF( final PdfCopy target, final PdfReader source )

           throws BadPdfFormatException, IOException

     {

           final int pages = source.getNumberOfPages();

           for ( int i = 1; i <= pages; i++ )

           {

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

           }

     }

 

 

Thank you,

Alexandre Pichtchikov

 

From: iText mailing list [mailto:[hidden email]]
Sent: Thursday, August 07, 2014 10:16 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

 

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:

    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 pages

        ByteArrayOutputStream 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, 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.

It looks like NullPointerException(PdfCopy.java:890) is generated at this line:

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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
In reply to this post by info-2

Hello,

Thanks a lot for the replay.

Yes, my bad, I should include appendPDF method from the beginning.

Here is the code :
     private static final void appendPDF( final PdfCopy target, final PdfReader source )

           throws BadPdfFormatException, IOException

     {

           final int pages = source.getNumberOfPages();

           for ( int i = 1; i <= pages; i++ )

           {

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

           }

     }

 

 

                In addition to the information above, byteArray used to createbasePDF reader is creating from XML transformed using JClass:

 

                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

                {

                     JCDocument jcDocument =

                           new JCDocument(

                                outputStream,

                                JCPageTemplate.loadTemplates( new ByteArrayInputStream( templateXML ) ) );

 

                     JCPrinter printer = jcDocument.getPrinter();

                     if (printer instanceof JCPDFPrinter) {

                           // Add pdf tags for accessibility

                           JCPDFPrinter pdfPrinter = (JCPDFPrinter)printer;

                           pdfPrinter.setLogicallyStructured(true);

                     }

 

                     jcDocument.setXMLLoadProperties( loadProperties );

                     jcDocument.setUserObject( new StatementUserObject( statementConfig, language ) );

                     jcDocument.loadXML( new ByteArrayInputStream( transformedXML ) );

                     jcDocument.print();

                     byteArray = outputStream.toByteArray();

                }

 

Thank you,

Alexandre Pichtchikov

 

From: iText mailing list [[hidden email]]
Sent: Thursday, August 07, 2014 10:16 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

 

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:

    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 pages

        ByteArrayOutputStream 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, 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.

It looks like NullPointerException(PdfCopy.java:890) is generated at this line:

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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

info-2
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.

------------------------------------------------------------------------------
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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
In reply to this post by Pichtchikov, Alexandre

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:[hidden email]]
Sent: Thursday, August 07, 2014 2:22 PM
To: [hidden email]
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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

info-2
On 8/8/2014 7:47 AM, Pichtchikov, Alexandre wrote:
Is something missing?
Maybe the document you're trying to copy isn't a properly tagged PDF.

------------------------------------------------------------------------------
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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre

Thanks a lot and sorry for the late replay.

What is the best way to check if my pdf tagged properly?

Thanks,

Alex

 

From: iText mailing list [mailto:[hidden email]]
Sent: Friday, August 08, 2014 11:43 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

 

On 8/8/2014 7:47 AM, Pichtchikov, Alexandre wrote:

Is something missing?

Maybe the document you're trying to copy isn't a properly tagged PDF.


------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

info-2
On 8/12/2014 8:27 AM, Pichtchikov, Alexandre wrote:
What is the best way to check if my pdf tagged properly?

It takes a human to do that.
No machine can ever know if a PDF is properly tagged.
Compare the PDF/UA specification with the Matterhorn protocol for more info.

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

mkl
Alexandre, Bruno,
iText mailing list wrote
On 8/12/2014 8:27 AM, Pichtchikov, Alexandre wrote:
> What is the best way to check if my pdf tagged properly?

It takes a human to do that.
No machine can ever know if a PDF is properly tagged.
Compare the PDF/UA specification with the Matterhorn protocol for more info.
@Bruno
While this certainly is true for a complete check, I assume Alexandre would be happy to have one check which would guarantee that the tagging will not give rise to the NullPointerException this thread is about.

@Alexandre
Have you checked whether a document causing that Exception in one case always does so? In that case an obvious check would be to try once.

regards,   Michael
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
In reply to this post by info-2

Ok, I got, thanks a lot.

 

From: iText mailing list [mailto:[hidden email]]
Sent: Wednesday, August 13, 2014 3:24 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

 

On 8/12/2014 8:27 AM, Pichtchikov, Alexandre wrote:

What is the best way to check if my pdf tagged properly?


It takes a human to do that.
No machine can ever know if a PDF is properly tagged.
Compare the PDF/UA specification with the Matterhorn protocol for more info.


------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [SPAM] Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
In reply to this post by mkl
Thanks a lot for your response Michael,
Answer is yes, the document always throw this exception when I try to use tagging related methods (setTagged + getImportedPage( source, i , true))
Thanks, Alex

-----Original Message-----
From: mkl [mailto:[hidden email]]
Sent: Wednesday, August 13, 2014 6:06 AM
To: [hidden email]
Subject: [iText-questions] [SPAM] Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Alexandre, Bruno,

iText mailing list wrote
> On 8/12/2014 8:27 AM, Pichtchikov, Alexandre wrote:
>> What is the best way to check if my pdf tagged properly?
>
> It takes a human to do that.
> No machine can ever know if a PDF is properly tagged.
> Compare the PDF/UA specification with the Matterhorn protocol for more
> info.

@Bruno
While this certainly is true for a complete check, I assume Alexandre would
be happy to have one check which would guarantee that the tagging will not
give rise to the NullPointerException this thread is about.

@Alexandre
Have you checked whether a document causing that Exception in one case
always does so? In that case an obvious check would be to try once.

regards,   Michael



--
View this message in context: http://itext-general.2136553.n4.nabble.com/method-PdfCopy-fixTaggedStructure-throws-NullPointerException-tp4660201p4660230.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

info-2
In reply to this post by Pichtchikov, Alexandre
On 8/13/2014 1:19 PM, Pichtchikov, Alexandre wrote:
Ok, I got, thanks a lot.
As Michael indicated, I misunderstood the question because I didn't look at the context.
Without you showing us the PDF that causes the problem (and a SSCCE), we can only guess about the nature of the problem.
For instance: the question you posted on August 7 showed that you didn't use iText correctly, which resulting in an obvious error.
(But I already answered that question, explaining what you did wrong.)


------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre

Thanks you for the answer. Can I send examples as attachment using the same email address?

 

From: iText mailing list [mailto:[hidden email]]
Sent: Wednesday, August 13, 2014 7:53 AM
To: [hidden email]
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

 

On 8/13/2014 1:19 PM, Pichtchikov, Alexandre wrote:

Ok, I got, thanks a lot.

As Michael indicated, I misunderstood the question because I didn't look at the context.
Without you showing us the PDF that causes the problem (and a SSCCE), we can only guess about the nature of the problem.
For instance: the question you posted on August 7 showed that you didn't use iText correctly, which resulting in an obvious error.
(But I already answered that question, explaining what you did wrong.)


------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

mkl
Alexandre,
Pichtchikov, Alexandre wrote
Can I send examples as attachment using the same email address?
Yes, simply send them attached to an e-mail to the mailing list. Be aware, though, of the size restrictions many SMTP servers have. Sizes larger than 15 MB after encoding might be rejected.

Regards,   Michael
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [SPAM] Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
Hello Michael,
Here is an example of tagged pdf I tried to use with iText.
Thanks,
Alex

-----Original Message-----
From: mkl [mailto:[hidden email]]
Sent: Wednesday, August 13, 2014 10:01 AM
To: [hidden email]
Subject: [iText-questions] [SPAM] Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Alexandre,

Pichtchikov, Alexandre wrote
> Can I send examples as attachment using the same email address?

Yes, simply send them attached to an e-mail to the mailing list. Be aware,
though, of the size restrictions many SMTP servers have. Sizes larger than
15 MB after encoding might be rejected.

Regards,   Michael



--
View this message in context: http://itext-general.2136553.n4.nabble.com/method-PdfCopy-fixTaggedStructure-throws-NullPointerException-tp4660201p4660235.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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

statement.output.pdf (56K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Raf Hens
On 13/08/2014 16:16, Pichtchikov, Alexandre wrote:
> Here is an example of tagged pdf I tried to use with iText.

Hi Alexandre,

Your tagged PDF seems fine.  The problem is that you're merging a tagged
and untagged PDF.

In your appendPDF() method, you now use:
target.addPage(target.getImportedPage(source, i, true));

This is okay for the tagged PDF, but for the untagged it will try to
preserve the structure which is not there.  A simple fix:
target.addPage(target.getImportedPage(source, i, source.isTagged()));


Alternatively, you can replace your appendPDF() method with
PdfCopy.addDocument().  This method detects if the document is tagged or
not.  In your code:
newPDF.addDocument(basePDF);
newPDF.addDocument(legendInformation);


Also, make sure you are creating tagged output.  In your code:
newPDF.setTagged();


Best regards,

Raf Hens
iText Software

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: method PdfCopy.fixTaggedStructure throws NullPointerException

Pichtchikov, Alexandre
Thanks a lot for your help!

-----Original Message-----
From: Raf Hens [mailto:[hidden email]]
Sent: Wednesday, September 10, 2014 6:57 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] method PdfCopy.fixTaggedStructure throws NullPointerException

On 13/08/2014 16:16, Pichtchikov, Alexandre wrote:
> Here is an example of tagged pdf I tried to use with iText.

Hi Alexandre,

Your tagged PDF seems fine.  The problem is that you're merging a tagged
and untagged PDF.

In your appendPDF() method, you now use:
target.addPage(target.getImportedPage(source, i, true));

This is okay for the tagged PDF, but for the untagged it will try to
preserve the structure which is not there.  A simple fix:
target.addPage(target.getImportedPage(source, i, source.isTagged()));


Alternatively, you can replace your appendPDF() method with
PdfCopy.addDocument().  This method detects if the document is tagged or
not.  In your code:
newPDF.addDocument(basePDF);
newPDF.addDocument(legendInformation);


Also, make sure you are creating tagged output.  In your code:
newPDF.setTagged();


Best regards,

Raf Hens
iText Software

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
[hidden email]
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

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
[hidden email]
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
Loading...