pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sridhar (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-3133) PDFBox 2.0.0-RC2 and earlier 2.0.0 SNAPSHOT Versions print performance is poor with systems having low RAM < 3GB and lower number of fonts.
Date Fri, 04 Dec 2015 09:51:11 GMT

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

Sridhar commented on PDFBOX-3133:

Dear Tilman

I need one urgent help

Planning the following work around.
I am using the code given below.  In that
job.print(attr)  takes all the 20 sec in low end client machine

If I create a printable Image / JPG using APIs similar to command line PDFToImage in Server
( which is very high end cluster and may finish all in < 1 sec ) and send
JPG Byte Stream to client side, 
What should be the code or PDFBox API or Java.awt.print  code to print JPG file at client
I did a quick browse through on PDFBOx APIs or Java.awt.print APIs but could not find, hence
this request to you.

PDF file Input to printable   JPG  PDFBox code sample
JPG bytestream to silent printing either PDFBox or Java.awt.print code
Code snippet for 1 and 2 will resolve our issue.

Code used

{ f = new File("Test.pdf" ) ; is = new FileInputStream(f) ; pdDocument = PDDocument.load(is);
printWithPaper(pdDocument, "SLEEK") ; }
private static void printWithPaper(PDDocument document, String receiptType)
{ PrinterJob job = PrinterJob.getPrinterJob(); job.setPageable(new PDFPageable(document, Orientation.AUTO,
true, 300) ) ; Book book = new Book(); book.append(new PDFPrintable(document, Scaling.ACTUAL_SIZE,
true, 300), getPageFormat("SLEEK") , document.getNumberOfPages()); job.setPageable(book);
PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet(); job.print(attr); }
private static PageFormat getPageFormat(String receiptType) {
PageFormat pageFormat = new PageFormat();
Paper paper= pageFormat.getPaper();
if ("SLEEK".equalsIgnoreCase(receiptType))
{ paperWidth = 3.14; paperHeight = 50; }
else if
{ //........ }

paper.setSize(paperWidth * 72.0, paperHeight * 72.0);
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
return pageFormat;

Sridhar Sowmiyanarayanan
Tata Consultancy Services
Mailto: sridhar.so@tcs.com
Website: http://www.tcs.com

> PDFBox 2.0.0-RC2 and earlier 2.0.0 SNAPSHOT Versions print performance is poor with systems
having low RAM < 3GB and lower number of fonts.
> -------------------------------------------------------------------------------------------------------------------------------------------
>                 Key: PDFBOX-3133
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3133
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 2.0.0
>         Environment: MS Windows Systems with low RAM < 3GB and number of fonts were
less < 592 (or if desired fonts in PDF to be printed are not available in local system
>            Reporter: Sridhar
>            Assignee: John Hewson
>              Labels: performance
>             Fix For: 2.0.0
> PDFBox 2.0.0-RC1, SNAPSHOTS and RC2 versions print takes 15+ seconds.
> Steps to reproduce
> -------------------------- 
> Use Windows System with < 3 GB RAM
> Use Systems with less number of fonts or without specific fonts in PDF file  to be printed.
> Printing PDF file 
> Took 14 to 20 seconds in system with 3 GB RAM which had 522 foints
> Took 24 to 34 seconds in system with 2 GB RAM which had 90 fonts
> Took only 2.5 seconds in system with 8 GB RAM which had 1025 fonts. 
> Doubt
> -------- 
> Not browsed the code, but following is the doubt as causing performance issue.
> Though the code caches fonts by storing fonts in local .pdfbox.cache file first time
and caching fonts for subsequent times.
> Not clear whether the code updates the pdfbox fonts cache file if new fonts are found
in new PDF file to be printed, while printing subsequent times. 
> If the fonts in PDF file to be printed is not available in the .pdfbox.cache file stored
in local system/local system what is the behaviour?  Will the code download fonts and update
cache for subsequent times or is it limited by fonts available in local system?  Looks like
later is the case and performance got hit either due to RAM or not constantly updating fonts
cache or due to un availability of fonts in local system.

This message was sent by Atlassian JIRA

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

View raw message