[ 
https://issues.apache.org/jira/browse/PDFBOX-5217?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr updated PDFBOX-5217:
------------------------------------
    Comment: was deleted

(was: Thanks, but we don't need this example, PDFToImage and PDFDebugger both 
support the subsampling option (which will not always help with OOMs).

(But yes, the FAQ should be updated to mention the subsampling trick  
[~msahyoun] )

The build fail is probably a jdk bug. I tried a local build on a W10 system 
with Amazon Corretto 1.8.0_292 and it went fine.)

> Rendering takes up too much memory, easy OOM
> --------------------------------------------
>
>                 Key: PDFBOX-5217
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5217
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Rendering
>    Affects Versions: 2.0.24, 3.0.0 PDFBox
>         Environment: Oracle JDK 1.8.0_291-b10
> MacOS BigSur  (CPU i5, RAM8GB)
> Windows 10 (CPU  i7  2.80GHz, RAM 16GB)
>            Reporter: lanshiqin
>            Priority: Major
>
> Conversion of a 20MB PDF file to an image resource consumes more than 8GB of 
> memory and takes 5 minutes. That's an intolerable fact.
> Debug found that the memory soared when the file stream was finally read.
> This is my code:
>  
> {code:java}
> try(InputStream in = new URL(pdfFileUrl).openStream();
>     PDDocument document = PDDocument.load(in, 
> MemoryUsageSetting.setupTempFileOnly())){
>     document.setResourceCache(null);
>     PDFRenderer renderer = new PDFRenderer(document);
>     List<String> imgUrlList = Lists.newArrayList();
>     for (int i = 0; i < document.getNumberOfPages(); i++) {
>         BufferedImage bufferedImage = renderer.renderImageWithDPI(i, DPI);
>         File tempFile = new File(OFFICE_CONVERT_TEMP_DIR + fileName + "_" + 
> i);
>         try {
>             ImageIO.write(bufferedImage, "png", tempFile);
>             imgUrlList.add("upload to media center get url todo "+i);
>         } finally {
>             FileUtils.deleteQuietly(tempFile);
>             bufferedImage.getGraphics().dispose();
>         }
>     }
>     return imgUrlList;
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to