pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tilman Hausherr (Jira)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-4649) High CPU load an memory usage, when converting PDF to Image
Date Thu, 12 Sep 2019 17:21:00 GMT

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

Tilman Hausherr commented on PDFBOX-4649:
-----------------------------------------

You should also check whether you have the same memory usage when using PDFToImage on your
system (see command line tools). OTOH I see that you never mentioned your dpi.

> 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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Mime
View raw message