[ https://issues.apache.org/jira/browse/PDFBOX-4649?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16927948#comment-16927948 ]
Tilman Hausherr commented on PDFBOX-4649: ----------------------------------------- Very weird... make sure you have the latest java version, I think for 1.8 the latest with the old oracle license was 192 or 202. Or use amazon corretto. I found one weird thing: from the command line, I could render {{331577-5_b_19ez1.pdf}} with -Xmx2g in rgb. But for bitonal (which you use) I needed -Xmx2400m to make it work. (java itself is at fault, sometimes it converts to rgb internally) You could use less memory by using a scratch file setting in PDDocument.load(), but then it will be much slower. > High CPU load an memory usage, when converting PDF to Image > ----------------------------------------------------------- > > Key: PDFBOX-4649 > URL: https://issues.apache.org/jira/browse/PDFBOX-4649 > Project: PDFBox > Issue Type: Bug > Components: Rendering > Affects Versions: 2.0.16 > Reporter: Willie Chieukam > Priority: Critical > Attachments: 331577-5_b_19ez1.pdf, 332699-5_c_19ez7.pdf, > 335520-5_c_19ezb.pdf, 335521-5_c_19ezd.pdf > > > Hello! > we are running a business web application, that is using pdfbox to convert > pdf-files to images using using pdfRenderer.renderImageWithDPI(parameters). > When we try to convert the attached pdf, the CPU load of tomcat, running in a > docker container on openshift, is raising and it seems, that the process > hangs. The tomcat process is no more responsive and we get an memory > overflow. Also the server load is very high meanwhile. > We are using > + org.apache.pdfbox:pdfbox v 2.0.16 > + org.apache.pdfbox:pdfbox-tools v 2.0.16 > + org.apache.pdfbox:jbig2-imageio:3.0.2 > Our Code looks like this: > {code:java} > public void saveImageFromPDF(Path filePath, Path imagePath, Integer > IMAGE_DPI, Float IMAGE_QUALITY) { > try (PDDocument pddocument = > PDDocument.load(Files.newInputStream(filePath, StandardOpenOption.READ))) { > PDFRenderer pdfRenderer = new PDFRenderer(pddocument); > for (Integer i = 0; i < pddocument.getNumberOfPages(); i++) { > try (OutputStream outputStream = documentServiceUtility > > .getFileOutputStream(imagePath.resolve(Integer.toString(i) + "." + > IMAGE_FILE_EXTENSION))) { > BufferedImage bufferedImage = > pdfRenderer.renderImageWithDPI(i, IMAGE_DPI, ImageType.BINARY); > ImageIOUtil.writeImage(bufferedImage, > IMAGE_FILE_EXTENSION, outputStream, IMAGE_DPI, IMAGE_QUALITY); > LOG.debug("Image of document {} successfully saved.", > imagePath.resolve(Integer.toString(i) + "." + > IMAGE_FILE_EXTENSION)); > } catch (Throwable ex) { > throw new NiehoffPDDocumentHanderException(filePath, ex); > } > } > } catch (Exception e) { > throw new NiehoffPDDocumentHanderException(filePath, e); > } > } > {code} > Line throwing the exception > *{color:#FF0000}BufferedImage bufferedImage = > pdfRenderer.renderImageWithDPI(i, IMAGE_DPI, ImageType.BINARY);{color}* > > Do you have an idea, how to prevent this? > Thank you very much and best regards, > Willie -- This message was sent by Atlassian Jira (v8.3.2#803003) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org