pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "von Daak, Frank" <Frank.vonD...@subreport.de>
Subject High CPU load an memory usage, when converting PDF to Image
Date Wed, 22 Jul 2015 04:46:37 GMT

We are running a business web application, that is using pdfbox to convert pdf-files to images,
using PDPage.convertToImage().
When we try to convert the attached pdf, the CPU load of tomcat is raising and it seems, that
the process hangs. The tomcat process is no more responsive and after a long while, we get
an memory overflow. Also the server load is very high meanwhile. 
We have seen this on pdfbox 1.8.8, 1.8.9 and 1.8.11-SNAPSHOT

Do you have an idea, how to prevent this?

Our code looks like this:

private void convertPDF2JPG(File inFile, String outFile) throws Exception {
PDDocument pdf = PDDocument.load(inFile);
List<PDPage> allPages = (List<PDPage>)pdf.getDocumentCatalog().getAllPages();

for (PDPage pdPage : allPages ) { 
int resolution = 220;
BufferedImage bufferedImage = pdPage.convertToImage(BufferedImage.TYPE_INT_RGB, resolution);
Graphics2D bufImageGraphics = bufferedImage.createGraphics();
bufImageGraphics.drawImage(bufferedImage, 0, 0, null);

convertAnyImage2JPG(bufferedImage, new File(outFile));


Thank you very much and best regards,

View raw message