pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Performance issue with page to image conversion between PDFBox versions
Date Tue, 16 Oct 2018 19:40:43 GMT
Hi,

Please update to 2.0.12 and share the PDF file (upload to a sharehoster).

What jdk are you using? Did you set that KCMS parameter?
https://pdfbox.apache.org/2.0/getting-started.html

Was the rendering result mostly identical?

No there is no standard way to get it faster except from that website... 
I could have a look if I get the file to see if there is some sort of 
bottleneck. Sometimes we find ways to optimize our code even further,
https://issues.apache.org/jira/browse/PDFBOX-3791?jql=labels%20%3D%20optimization
which is why you should always use the latest version.

Tilman

Am 16.10.2018 um 20:14 schrieb Kalyan Donda:
> Hi,
>
>    We have a PDF document with an image on each page and we have code to
> extract and process those images in a Java program.
>
>    We used to have the following lines of code to extract an image from a
> PDF page using PDFBox 1.8.13 and the time it takes is 119 milliseconds.
>
>      PDDocument document = PDDocument.load(file);
>      PDDocumentCatalog pdc = document.getDocumentCatalog();
>      List pages = pdc.getAllPages();
>      Iterator iter = pages.iterator();
>      while (iter.hasNext()) {
>        PDPage pg = (PDPage) iter.next();
>        BufferedImage bi = pg.convertToImage(BufferedImage.TYPE_BYTE_GRAY,
> 288);
>        .... Code that processes the above buffered image
>      }
>
>    But when we moved to PDFBox 2.0.9 we had to convert the above code to the
> following as convertToImage is deprecared ,but this code is taking 4 to 10
> times more time (823 milliseconds compared to 119 in previous version as an
> example for a page). Is there any better way of extracting the image with
> 288 DPI and have the performance of the old version of API?
>
>      PDDocument document = PDDocument.load(file);
>      PDFRenderer pdfRenderer = new PDFRenderer(document);
>      int totalPages = document.getNumberOfPages();
>      int currentPageCount = -1;
>      while (++currentPageCount < totalPages) {
>        BufferedImage bi = pdfRenderer.renderImageWithDPI(currentPageCount,
> 288, ImageType.GRAY);
>        .... Code that processes the above buffered image
>      }
>
> Regards
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message