Question

I am having Force Close in my application, when i choose a file1(size: 33,016,510 - not sure if byte or kb) but when i try a file2(size: 604,612) it does not force close. How much file size can iTextPDF can read?

file1: 400-500pages, Has Image Background and Images, but Text are all HIGHLIGHTABLE so meaning text can be READ(This is how I determine if the contents of PDF are text or images, Correct me if i am wrong).

file2: 30-50pages, has images and no background.

I have ideas why it force closes.

  1. Because of the PDF file size.
  2. The Code it self.
  3. The contents of the PDF.

The code i use to read PDF:

page_Content = PdfTextExtractor.getTextFromPage(
                    reader, 0, new SimpleTextExtractionStrategy());

What's the problem here?

Comment below if the information is lacking.

Exception:

12-26 19:20:19.026: E/AndroidRuntime(1119): FATAL EXCEPTION: main
12-26 19:20:19.026: E/AndroidRuntime(1119): java.lang.OutOfMemoryError
12-26 19:20:19.026: E/AndroidRuntime(1119):     at java.util.ArrayList.add(ArrayList.java:123)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfArray.add(PdfArray.java:269)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.readArray(PdfReader.java:1608)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.readPRObject(PdfReader.java:1657)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.readDictionary(PdfReader.java:1588)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.readPRObject(PdfReader.java:1624)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.readDocObj(PdfReader.java:1143)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:511)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:170)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:159)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.example.panalyzerdemo.InformationRetrieval.pdfFilePath(InformationRetrieval.java:54)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.example.panalyzerdemo.MainActivity.onActivityResult(MainActivity.java:207)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.app.Activity.dispatchActivityResult(Activity.java:3890)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3514)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3560)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.app.ActivityThread.access$2800(ActivityThread.java:128)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.os.Looper.loop(Looper.java:123)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at android.app.ActivityThread.main(ActivityThread.java:4644)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at java.lang.reflect.Method.invokeNative(Native Method)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at java.lang.reflect.Method.invoke(Method.java:521)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
12-26 19:20:19.026: E/AndroidRuntime(1119):     at dalvik.system.NativeStart.main(Native Method)
Was it helpful?

Solution

I have solved my problem with large PDF files. What I will do is NOT to read the whole PDF file but to read 50-100 pages first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top