You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "von Daak, Frank" <Fr...@subreport.de> on 2015/07/22 06:46:37 UTC

High CPU load an memory usage, when converting PDF to Image

Hello!

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);
bufImageGraphics.dispose();

convertAnyImage2JPG(bufferedImage, new File(outFile));
}

}


Thank you very much and best regards,
Frank


Re: High CPU load an memory usage, when converting PDF to Image

Posted by "von Daak, Frank" <Fr...@subreport.de>.
Wow - works like a charm...

Great work! Thank you very much!

Best regards,
Frank von Daak



Am 22.07.2015 um 19:28 schrieb Tilman Hausherr <TH...@t-online.de>:

> Am 22.07.2015 um 18:25 schrieb Tilman Hausherr:
>> Am 22.07.2015 um 16:21 schrieb von Daak, Frank:
>>> Great. Thank you for your help!
>>> 
>>> For us, it would be enough to identify such a file, before calling convertToImage(), to avoid the high server load.
>>> Do you think, there is a way to get this information out of the pdf?
>> 
>> Sadly, no; but I will do the second best, fix the bug this evening. Details here:
>> https://issues.apache.org/jira/browse/PDFBOX-2901
> 
> new snapshot for 1.8.11 should be available now.
> 
> Tilman
> 
> 
>> 
>> Tilman
>> 
>>> 
>>> Greets,
>>> Frank
>>> 
>>> 
>>> 
>>> Am 22.07.2015 um 09:01 schrieb Tilman Hausherr <TH...@t-online.de>:
>>> 
>>>> Thanks. According to virustotal.com, one (Dr.Web) of 51 programs claims that it is a virus (SCRIPT.Virus). I've send it to them for analysis. In the meantime, I'm also trying to display that file with 2.0 and nothing happens except my CPU heating the room. Either we have a new bug, or the file is really very complex.
>>>> 
>>>> Reminds me that I have the same problem with this file:
>>>> http://bugs.ghostscript.com/show_bug.cgi?id=692158
>>>> 
>>>> Tilman
>>>> 
>>>> Am 22.07.2015 um 08:11 schrieb von Daak, Frank:
>>>>> Hi,
>>>>> 
>>>>> ah, ok.
>>>>> 
>>>>> Please find the pdf file at the following location:
>>>>> http://82.165.25.239/buggypdf_nurgrafik.pdf
>>>>> 
>>>>> Greetings,
>>>>> Frank
>>>>> 
>>>>> 
>>>>> 
>>>>> Am 22.07.2015 um 07:11 schrieb Tilman Hausherr <TH...@t-online.de>:
>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> It is not possible to attach PDFs here, please upload it somewhere so that we can have a look.
>>>>>> 
>>>>>> Tilman
>>>>>> 
>>>>>> Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
>>>>>>> Hello!
>>>>>>> 
>>>>>>> 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);
>>>>>>> bufImageGraphics.dispose();
>>>>>>> 
>>>>>>> convertAnyImage2JPG(bufferedImage, new File(outFile));
>>>>>>> }
>>>>>>> 
>>>>>>> }
>>>>>>> 
>>>>>>> 
>>>>>>> Thank you very much and best regards,
>>>>>>> Frank
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> --------------------------------------------------------------------- 
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 

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


Re: High CPU load an memory usage, when converting PDF to Image

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 22.07.2015 um 18:25 schrieb Tilman Hausherr:
> Am 22.07.2015 um 16:21 schrieb von Daak, Frank:
>> Great. Thank you for your help!
>>
>> For us, it would be enough to identify such a file, before calling 
>> convertToImage(), to avoid the high server load.
>> Do you think, there is a way to get this information out of the pdf?
>
> Sadly, no; but I will do the second best, fix the bug this evening. 
> Details here:
> https://issues.apache.org/jira/browse/PDFBOX-2901

new snapshot for 1.8.11 should be available now.

Tilman


>
> Tilman
>
>>
>> Greets,
>> Frank
>>
>>
>>
>> Am 22.07.2015 um 09:01 schrieb Tilman Hausherr <TH...@t-online.de>:
>>
>>> Thanks. According to virustotal.com, one (Dr.Web) of 51 programs 
>>> claims that it is a virus (SCRIPT.Virus). I've send it to them for 
>>> analysis. In the meantime, I'm also trying to display that file with 
>>> 2.0 and nothing happens except my CPU heating the room. Either we 
>>> have a new bug, or the file is really very complex.
>>>
>>> Reminds me that I have the same problem with this file:
>>> http://bugs.ghostscript.com/show_bug.cgi?id=692158
>>>
>>> Tilman
>>>
>>> Am 22.07.2015 um 08:11 schrieb von Daak, Frank:
>>>> Hi,
>>>>
>>>> ah, ok.
>>>>
>>>> Please find the pdf file at the following location:
>>>> http://82.165.25.239/buggypdf_nurgrafik.pdf
>>>>
>>>> Greetings,
>>>> Frank
>>>>
>>>>
>>>>
>>>> Am 22.07.2015 um 07:11 schrieb Tilman Hausherr 
>>>> <TH...@t-online.de>:
>>>>
>>>>> Hi,
>>>>>
>>>>> It is not possible to attach PDFs here, please upload it somewhere 
>>>>> so that we can have a look.
>>>>>
>>>>> Tilman
>>>>>
>>>>> Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
>>>>>> Hello!
>>>>>>
>>>>>> 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);
>>>>>> bufImageGraphics.dispose();
>>>>>>
>>>>>> convertAnyImage2JPG(bufferedImage, new File(outFile));
>>>>>> }
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Thank you very much and best regards,
>>>>>> Frank
>>>>>>
>>>>>>
>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


Re: High CPU load an memory usage, when converting PDF to Image

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 22.07.2015 um 16:21 schrieb von Daak, Frank:
> Great. Thank you for your help!
>
> For us, it would be enough to identify such a file, before calling convertToImage(), to avoid the high server load.
> Do you think, there is a way to get this information out of the pdf?

Sadly, no; but I will do the second best, fix the bug this evening. 
Details here:
https://issues.apache.org/jira/browse/PDFBOX-2901

Tilman

>
> Greets,
> Frank
>
>   
>
>
> Am 22.07.2015 um 09:01 schrieb Tilman Hausherr <TH...@t-online.de>:
>
>> Thanks. According to virustotal.com, one (Dr.Web) of 51 programs claims that it is a virus (SCRIPT.Virus). I've send it to them for analysis. In the meantime, I'm also trying to display that file with 2.0 and nothing happens except my CPU heating the room. Either we have a new bug, or the file is really very complex.
>>
>> Reminds me that I have the same problem with this file:
>> http://bugs.ghostscript.com/show_bug.cgi?id=692158
>>
>> Tilman
>>
>> Am 22.07.2015 um 08:11 schrieb von Daak, Frank:
>>> Hi,
>>>
>>> ah, ok.
>>>
>>> Please find the pdf file at the following location:
>>> http://82.165.25.239/buggypdf_nurgrafik.pdf
>>>
>>> Greetings,
>>> Frank
>>>
>>>
>>>
>>> Am 22.07.2015 um 07:11 schrieb Tilman Hausherr <TH...@t-online.de>:
>>>
>>>> Hi,
>>>>
>>>> It is not possible to attach PDFs here, please upload it somewhere so that we can have a look.
>>>>
>>>> Tilman
>>>>
>>>> Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
>>>>> Hello!
>>>>>
>>>>> 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);
>>>>> bufImageGraphics.dispose();
>>>>>
>>>>> convertAnyImage2JPG(bufferedImage, new File(outFile));
>>>>> }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> Thank you very much and best regards,
>>>>> Frank
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


Re: High CPU load an memory usage, when converting PDF to Image

Posted by "von Daak, Frank" <Fr...@subreport.de>.
Great. Thank you for your help!

For us, it would be enough to identify such a file, before calling convertToImage(), to avoid the high server load.
Do you think, there is a way to get this information out of the pdf?

Greets,
Frank

 


Am 22.07.2015 um 09:01 schrieb Tilman Hausherr <TH...@t-online.de>:

> Thanks. According to virustotal.com, one (Dr.Web) of 51 programs claims that it is a virus (SCRIPT.Virus). I've send it to them for analysis. In the meantime, I'm also trying to display that file with 2.0 and nothing happens except my CPU heating the room. Either we have a new bug, or the file is really very complex.
> 
> Reminds me that I have the same problem with this file:
> http://bugs.ghostscript.com/show_bug.cgi?id=692158
> 
> Tilman
> 
> Am 22.07.2015 um 08:11 schrieb von Daak, Frank:
>> Hi,
>> 
>> ah, ok.
>> 
>> Please find the pdf file at the following location:
>> http://82.165.25.239/buggypdf_nurgrafik.pdf
>> 
>> Greetings,
>> Frank
>> 
>> 
>> 
>> Am 22.07.2015 um 07:11 schrieb Tilman Hausherr <TH...@t-online.de>:
>> 
>>> Hi,
>>> 
>>> It is not possible to attach PDFs here, please upload it somewhere so that we can have a look.
>>> 
>>> Tilman
>>> 
>>> Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
>>>> Hello!
>>>> 
>>>> 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);
>>>> bufImageGraphics.dispose();
>>>> 
>>>> convertAnyImage2JPG(bufferedImage, new File(outFile));
>>>> }
>>>> 
>>>> }
>>>> 
>>>> 
>>>> Thank you very much and best regards,
>>>> Frank
>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 

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


Re: High CPU load an memory usage, when converting PDF to Image

Posted by Tilman Hausherr <TH...@t-online.de>.
Thanks. According to virustotal.com, one (Dr.Web) of 51 programs claims 
that it is a virus (SCRIPT.Virus). I've send it to them for analysis. In 
the meantime, I'm also trying to display that file with 2.0 and nothing 
happens except my CPU heating the room. Either we have a new bug, or the 
file is really very complex.

Reminds me that I have the same problem with this file:
http://bugs.ghostscript.com/show_bug.cgi?id=692158

Tilman

Am 22.07.2015 um 08:11 schrieb von Daak, Frank:
> Hi,
>
> ah, ok.
>
> Please find the pdf file at the following location:
> http://82.165.25.239/buggypdf_nurgrafik.pdf
>
> Greetings,
> Frank
>
>
>
> Am 22.07.2015 um 07:11 schrieb Tilman Hausherr <TH...@t-online.de>:
>
>> Hi,
>>
>> It is not possible to attach PDFs here, please upload it somewhere so that we can have a look.
>>
>> Tilman
>>
>> Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
>>> Hello!
>>>
>>> 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);
>>> bufImageGraphics.dispose();
>>>
>>> convertAnyImage2JPG(bufferedImage, new File(outFile));
>>> }
>>>
>>> }
>>>
>>>
>>> Thank you very much and best regards,
>>> Frank
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


Re: High CPU load an memory usage, when converting PDF to Image

Posted by "von Daak, Frank" <Fr...@subreport.de>.
Hi,

ah, ok. 

Please find the pdf file at the following location:
http://82.165.25.239/buggypdf_nurgrafik.pdf

Greetings,
Frank



Am 22.07.2015 um 07:11 schrieb Tilman Hausherr <TH...@t-online.de>:

> Hi,
> 
> It is not possible to attach PDFs here, please upload it somewhere so that we can have a look.
> 
> Tilman
> 
> Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
>> Hello!
>> 
>> 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);
>> bufImageGraphics.dispose();
>> 
>> convertAnyImage2JPG(bufferedImage, new File(outFile));
>> }
>> 
>> }
>> 
>> 
>> Thank you very much and best regards,
>> Frank
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
> 

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


Re: High CPU load an memory usage, when converting PDF to Image

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

It is not possible to attach PDFs here, please upload it somewhere so 
that we can have a look.

Tilman

Am 22.07.2015 um 06:46 schrieb von Daak, Frank:
> Hello!
>
> 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);
> bufImageGraphics.dispose();
>
> convertAnyImage2JPG(bufferedImage, new File(outFile));
> }
>
> }
>
>
> Thank you very much and best regards,
> Frank
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org