Quantcast

Problem with large Pdf reading with PdfReader

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

Problem with large Pdf reading with PdfReader

hanmant.sapkal
Hello,

We are facing a problem while reading large Pdf files (around above 32
Meg with 5000 pages).
I am using itext-5.3.0 System configuration = Solaris with
Weblogic-9.2 and JVM HotSpot

I tried bellow constuctors to read the Pdf

1. PdfReader(byte[] pdfIn)
2. PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
3. PdfReader(String filename)

But all of above stuck when Pdf is larger than 32 Meg

java.lang.StackOverflowError
        at java.util.HashMap$KeySet.iterator(HashMap.java:867)
        at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
        at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
        at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)

Within my  application, i have a servlet which reads pdf file and
write to out-put stream. I have an intermediate Servlet Wrapper which
wraps this output-stream and pass data to PdfReader. Bellow are
alternative methods which i tried but unfortunatly each of them cause
same exception error.

Method 1: PdfReader(byte[] pdfIn)
--------------
PdfReader reader;
reader = new PdfReader(pdfWrapper.getData());
========================================

Method 2: PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
--------------
PdfReader reader;
RandomAccessFileOrArray raFileOrArray = new
RandomAccessFileOrArray(pdfWrapper.getData());
reader = new PdfReader(raFileOrArray, null);
========================================

Method 3:PdfReader(String filename)
--------------
PdfReader reader;
reader = new PdfReader("/tmp/large-file.pdf"); // this path has rw permission.
========================================

We also changed JVM Memory setting to...

-Xms2048m -Xmx4096m -XX:PermSize=512m -XX:MaxPermSize2048m
-XX:ThreadStackSize=512


So please help me out in this.

Regards,
Hanmant.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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
star

Re: Problem with large Pdf reading with PdfReader

Paulo Soares-4
PdfReader reader;
RandomAccessFileOrArray raFileOrArray = new
RandomAccessFileOrArray("/tmp/large-file.pdf");
reader = new PdfReader(raFileOrArray, null);

Paulo

On Fri, Jul 13, 2012 at 11:47 AM, Hanmant Sapkal
<[hidden email]> wrote:

> Hello,
>
> We are facing a problem while reading large Pdf files (around above 32
> Meg with 5000 pages).
> I am using itext-5.3.0 System configuration = Solaris with
> Weblogic-9.2 and JVM HotSpot
>
> I tried bellow constuctors to read the Pdf
>
> 1. PdfReader(byte[] pdfIn)
> 2. PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
> 3. PdfReader(String filename)
>
> But all of above stuck when Pdf is larger than 32 Meg
>
> java.lang.StackOverflowError
>         at java.util.HashMap$KeySet.iterator(HashMap.java:867)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>
> Within my  application, i have a servlet which reads pdf file and
> write to out-put stream. I have an intermediate Servlet Wrapper which
> wraps this output-stream and pass data to PdfReader. Bellow are
> alternative methods which i tried but unfortunatly each of them cause
> same exception error.
>
> Method 1: PdfReader(byte[] pdfIn)
> --------------
> PdfReader reader;
> reader = new PdfReader(pdfWrapper.getData());
> ========================================
>
> Method 2: PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
> --------------
> PdfReader reader;
> RandomAccessFileOrArray raFileOrArray = new
> RandomAccessFileOrArray(pdfWrapper.getData());
> reader = new PdfReader(raFileOrArray, null);
> ========================================
>
> Method 3:PdfReader(String filename)
> --------------
> PdfReader reader;
> reader = new PdfReader("/tmp/large-file.pdf"); // this path has rw permission.
> ========================================
>
> We also changed JVM Memory setting to...
>
> -Xms2048m -Xmx4096m -XX:PermSize=512m -XX:MaxPermSize2048m
> -XX:ThreadStackSize=512
>
>
> So please help me out in this.
>
> Regards,
> Hanmant.
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> 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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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
star

Re: Problem with large Pdf reading with PdfReader

hanmant.sapkal
PdfReader reader;
RandomAccessFileOrArray raFileOrArray = new
RandomAccessFileOrArray("/tmp/large-file.pdf");
reader = new PdfReader(raFileOrArray, null);

This also cause same exception:

java.lang.StackOverflowError
         at java.util.HashMap$KeySet.iterator(HashMap.java:867)
         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)

On Fri, Jul 13, 2012 at 4:26 PM, Paulo Soares <[hidden email]> wrote:

> PdfReader reader;
> RandomAccessFileOrArray raFileOrArray = new
> RandomAccessFileOrArray("/tmp/large-file.pdf");
> reader = new PdfReader(raFileOrArray, null);
>
> Paulo
>
> On Fri, Jul 13, 2012 at 11:47 AM, Hanmant Sapkal
> <[hidden email]> wrote:
>> Hello,
>>
>> We are facing a problem while reading large Pdf files (around above 32
>> Meg with 5000 pages).
>> I am using itext-5.3.0 System configuration = Solaris with
>> Weblogic-9.2 and JVM HotSpot
>>
>> I tried bellow constuctors to read the Pdf
>>
>> 1. PdfReader(byte[] pdfIn)
>> 2. PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
>> 3. PdfReader(String filename)
>>
>> But all of above stuck when Pdf is larger than 32 Meg
>>
>> java.lang.StackOverflowError
>>         at java.util.HashMap$KeySet.iterator(HashMap.java:867)
>>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>>
>> Within my  application, i have a servlet which reads pdf file and
>> write to out-put stream. I have an intermediate Servlet Wrapper which
>> wraps this output-stream and pass data to PdfReader. Bellow are
>> alternative methods which i tried but unfortunatly each of them cause
>> same exception error.
>>
>> Method 1: PdfReader(byte[] pdfIn)
>> --------------
>> PdfReader reader;
>> reader = new PdfReader(pdfWrapper.getData());
>> ========================================
>>
>> Method 2: PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
>> --------------
>> PdfReader reader;
>> RandomAccessFileOrArray raFileOrArray = new
>> RandomAccessFileOrArray(pdfWrapper.getData());
>> reader = new PdfReader(raFileOrArray, null);
>> ========================================
>>
>> Method 3:PdfReader(String filename)
>> --------------
>> PdfReader reader;
>> reader = new PdfReader("/tmp/large-file.pdf"); // this path has rw permission.
>> ========================================
>>
>> We also changed JVM Memory setting to...
>>
>> -Xms2048m -Xmx4096m -XX:PermSize=512m -XX:MaxPermSize2048m
>> -XX:ThreadStackSize=512
>>
>>
>> So please help me out in this.
>>
>> Regards,
>> Hanmant.
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> 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
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> 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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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
star

Re: Problem with large Pdf reading with PdfReader

John Renfrew
If you are using 5.0.3 how come you are getting com.lowagie.text.pdf errors??

Sent while on the move

On 13 Jul 2012, at 07:10, Hanmant Sapkal <[hidden email]> wrote:

> PdfReader reader;
> RandomAccessFileOrArray raFileOrArray = new
> RandomAccessFileOrArray("/tmp/large-file.pdf");
> reader = new PdfReader(raFileOrArray, null);
>
> This also cause same exception:
>
> java.lang.StackOverflowError
>         at java.util.HashMap$KeySet.iterator(HashMap.java:867)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>
> On Fri, Jul 13, 2012 at 4:26 PM, Paulo Soares <[hidden email]> wrote:
>> PdfReader reader;
>> RandomAccessFileOrArray raFileOrArray = new
>> RandomAccessFileOrArray("/tmp/large-file.pdf");
>> reader = new PdfReader(raFileOrArray, null);
>>
>> Paulo
>>
>> On Fri, Jul 13, 2012 at 11:47 AM, Hanmant Sapkal
>> <[hidden email]> wrote:
>>> Hello,
>>>
>>> We are facing a problem while reading large Pdf files (around above 32
>>> Meg with 5000 pages).
>>> I am using itext-5.3.0 System configuration = Solaris with
>>> Weblogic-9.2 and JVM HotSpot
>>>
>>> I tried bellow constuctors to read the Pdf
>>>
>>> 1. PdfReader(byte[] pdfIn)
>>> 2. PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
>>> 3. PdfReader(String filename)
>>>
>>> But all of above stuck when Pdf is larger than 32 Meg
>>>
>>> java.lang.StackOverflowError
>>>        at java.util.HashMap$KeySet.iterator(HashMap.java:867)

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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
star

Re: Problem with large Pdf reading with PdfReader

mkl
Hanmant,
John Renfrew wrote
If you are using 5.0.3 how come you are getting com.lowagie.text.pdf errors??

On 13 Jul 2012, at 07:10, Hanmant Sapkal <[hidden email]> wrote:

> java.lang.StackOverflowError
>         at java.util.HashMap$KeySet.iterator(HashMap.java:867)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
Furthermore com.lowagie.text.pdf.PdfReader.removeUnusedNode has not been recursive anymore since October 2006. That iText is not merely old, it's ancient.

Maybe, though, both an old and a new iText are in the classpath. In that case merely the OP's sources have to be updated.

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

Re: Problem with large Pdf reading with PdfReader

hanmant.sapkal
In reply to this post by John Renfrew
Thanks John,

You pinout exact cause. Now I can process large pdf files pretty good.

Here is what i did misteks.

1) I was using iText-2.7 which eventually fails to process large pdf
documents (larger than about 30 Megs).

2) while upgrating my code from iText-2.7 to iText-5.3.0, i was only
replacing library and leaving my classes unchanged. (compiled with
iText-2.7, this was reallly funny. But John pointout this. Thanks
John)

Conclusion, iText-5.3.0 can process larger pdf files, but iText-2.7
PdfReader fails to read large pdf document.



On Fri, Jul 13, 2012 at 4:44 PM, John Renfrew <[hidden email]> wrote:

> If you are using 5.0.3 how come you are getting com.lowagie.text.pdf errors??
>
> Sent while on the move
>
> On 13 Jul 2012, at 07:10, Hanmant Sapkal <[hidden email]> wrote:
>
>> PdfReader reader;
>> RandomAccessFileOrArray raFileOrArray = new
>> RandomAccessFileOrArray("/tmp/large-file.pdf");
>> reader = new PdfReader(raFileOrArray, null);
>>
>> This also cause same exception:
>>
>> java.lang.StackOverflowError
>>         at java.util.HashMap$KeySet.iterator(HashMap.java:867)
>>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>>         at com.lowagie.text.pdf.PdfReader.removeUnusedNode(Unknown Source)
>>
>> On Fri, Jul 13, 2012 at 4:26 PM, Paulo Soares <[hidden email]> wrote:
>>> PdfReader reader;
>>> RandomAccessFileOrArray raFileOrArray = new
>>> RandomAccessFileOrArray("/tmp/large-file.pdf");
>>> reader = new PdfReader(raFileOrArray, null);
>>>
>>> Paulo
>>>
>>> On Fri, Jul 13, 2012 at 11:47 AM, Hanmant Sapkal
>>> <[hidden email]> wrote:
>>>> Hello,
>>>>
>>>> We are facing a problem while reading large Pdf files (around above 32
>>>> Meg with 5000 pages).
>>>> I am using itext-5.3.0 System configuration = Solaris with
>>>> Weblogic-9.2 and JVM HotSpot
>>>>
>>>> I tried bellow constuctors to read the Pdf
>>>>
>>>> 1. PdfReader(byte[] pdfIn)
>>>> 2. PdfReader(RandomAccessFileOrArray raf, byte[] ownerPassword)
>>>> 3. PdfReader(String filename)
>>>>
>>>> But all of above stuck when Pdf is larger than 32 Meg
>>>>
>>>> java.lang.StackOverflowError
>>>>        at java.util.HashMap$KeySet.iterator(HashMap.java:867)
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> 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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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...