Hi,
I am developing a java web application where use will upload a pdf file and the
web application will convert the pdf to png images and send embedded html email.
The pdf is around 6 pages, the application takes around 9 sec to convert the
pdf to png using PDPage.convertToImage method.
When I do a load test of the application with 10 concurrent users the
page.convertToImage take around 60 secs.,
The performance decreases further if the concurrent users are more.
I am using pdfbox 1.8.2
Below is the code I am using to convert to image
PDDocument document = PDDocument.loadNonSeq(new File(pdfFileName), scratchFile);
List<PDPage> pageList = document.getDocumentCatalog().getAllPages();
int pageSize = pageList.size();
String[] retVal = new String[pageSize];
int imgType = BufferedImage.TYPE_BYTE_BINARY;
int i = 0;
for (PDPage page : pageList) {
BufferedImage image = page.convertToImage(imgType, 133);
if (image.getGraphics() != null) {
image.getGraphics().dispose();
}
ImageIOUtil.writeImage(image, "png", prefix + i, imgType, 133);
i++;
Let me know if there is any problem with the code. Below is the response out
from profiling web app
I user uploading 10 docs only by one (avg response around 9 sec)
[cid:[email protected]]
10 users uploading a doc at same time (avg response 66 secs)
[cid:[email protected]]
Let me know if I am doing any mistakes or converToImage can only be used in
desktop applications?
Thanks
Balaji Ranganathan
Java developer
________________________________
Confidentiality Notice: This e-mail is intended only for the person(s) to whom
it is addressed and may contain information that is confidential, proprietary,
privileged or otherwise protected from disclosure. If you are not an intended
recipient, please (i) do not read, copy or use this communication, or disclose
it to others, (ii) notify the sender immediately by replying to the message,
and (iii) delete the e-mail from your system. Thank you.