[ 
https://issues.apache.org/jira/browse/PDFBOX-1907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13904083#comment-13904083
 ] 

Maruan Sahyoun commented on PDFBOX-1907:
----------------------------------------

Glad, that it works now. You can improve the code a little by writing

TemporaryResources tmp = new TemporaryResources();
RandomAccess scratchFile = new RandomAccessFile(tmp.createTemporaryFile(), 
"rw");
pdfStripper = new PDFTextStripper();
pdDoc = PDDocument.loadNonSeq(file,scratchFile);
parsedText = pdfStripper.getText(pdDoc);

Generally it’s preferred to not use the parser directly if you work with the 
higher level PD Model.

To your questions
a) yes it will be slower
b) the RandomAccessFile will always be used not only on low memory
c) if TIKA ist not having the option to use the RandomAccessFile then it’s up 
to them to change that.

I know that there was a discussion in the past in the TIKA project to enable 
that but I don’t know if that has been implemented. If there is something we 
can do on our side we are open to do so as TIKA is an important integration in 
the market.



> Out of memory - heap space - COSDocument
> ----------------------------------------
>
>                 Key: PDFBOX-1907
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1907
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 1.8.4
>         Environment: windows xp 64
> jdk 8 32 bit
>            Reporter: Jim Kay
>              Labels: regression
>         Attachments: 8283.zip.001, 8283.zip.001, 8283.zip.002, 8283.zip.002, 
> 8283.zip.003, 8283.zip.003
>
>
> Possibly related to PDFBOX-1777.
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
>       at java.util.AbstractCollection.toArray(AbstractCollection.java:136)
>       at java.util.ArrayList.<init>(ArrayList.java:168)
>       at org.apache.pdfbox.cos.COSDocument.getObjects(COSDocument.java:518)
>       at org.apache.pdfbox.cos.COSDocument.getObjects(COSDocument.java:518)
>       at org.apache.pdfbox.cos.COSDocument.close(COSDocument.java:575)
>       at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:254)
>       at techref.Testpdfbox.main(Testpdfbox.java:36)
> The heap space is set to -Xmx1640m
> The pdf docoument is parsed OK with version 1.8.3 but fails with 1.8.4
> The large pdf document has the following attributes.
> pdDoc.getCurrentAccessPermission.canExtractContent = true
> pdDoc.getCurrentAccessPermission.canExtractForAccessibility = true
> pdDoc.getNumberOfPages = 228
> pdDoc.getDocumentCatalog.getLanguage = null
> pdDoc.getDocumentCatalog.getPageLayout = SinglePage
> pdDoc.getDocumentCatalog.getPageMode = UseNone
> pdDoc.getDocumentCatalog.getVersion = null
> Page Count=228
> Title=Microsoft Word - FEA.doc
> Author=null
> Subject=null
> Keywords=null
> Creator=Windows NT 4.0
> Producer=Acrobat Distiller 4.05 for Windows
> Creation Date=Fri Jun 29 15:29:59 BST 2001
> Modification Date=Mon Jul 02 15:41:18 BST 2001
> Trapped=null
> Dictionary=COSDictionary{(COSName{CreationDate}:COSString{D:20010629142959}) 
> (COSName{Producer}:COSString{Acrobat Distiller 4.05 for Windows}) 
> (COSName{Creator}:COSString{Windows NT 4.0}) 
> (COSName{Title}:COSString{Microsoft Word - FEA.doc}) 
> (COSName{ModDate}:COSString{D:20010702164118+02'00'}) }



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to