Hello,
For a specific Letter generation use-case I prepared a test of statistical
significance using a paired t-test for comparing the performance [1] of iText
vs a commercial PDF framework. The experiment shows that for our relevant
use-case iText underperforms by 30% with 95% confidence.
I did some further investigation of the iText code for this specific use-case
and found the following call to be among the top most expensive calls:
com.itextpdf.text.pdf.PdfStamperImpl.close (line 189) taking up to 195
milliseconds
The code that invokes such method is the following:
private static void appendFooter(PdfWriter writer) throws Exception {
Map<String, String> replacements = new HashMap<String, String>();
replacements.put("ph0001", "XXXXX XXXXX");
replacements.put("ph0002", "Head of Customer Acquisition");
replacements.put("ph0003", "XXXXXX XXXXXXX");
replacements.put("ph0004", "Head of Customer Satisfaction");
PdfReader footerReader = new PdfReader(FOOTER_PATH);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(footerReader, outputStream);
AcroFields form = stamper.getAcroFields();
for (Map.Entry<String, String> entry : replacements.entrySet()) {
form.setField(entry.getKey(), entry.getValue());
}
stamper.setFormFlattening(true);
stamper.close();
int pageOne = 1;
int xOffset = 5;
int yOffset = -560;
PdfReader memoryReader = new PdfReader(outputStream.toByteArray());
PdfImportedPage importedPage = writer.getImportedPage(memoryReader,
pageOne);
PdfContentByte content = writer.getDirectContent();
content.addTemplate(importedPage, xOffset, yOffset);
}
Are there any possible rewrites to avoid the expensive call?
Thanks in advance,
Best regards,
Giovanni
[1] The Art of Computer Systems Performance Analysis: Techniques for
Experimental Design, Measurement, Simulation, and Modeling
http://www.amazon.com/Art-Computer-Systems-Performance-Analysis/dp/0471503363/ref=cm_cr-mr-title
==============================================================================
Please access the attached hyperlink for an important electronic communications
disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/