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 18:34:11 GMT

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

Sridhar commented on PDFBOX-3133:
---------------------------------

Thanks a lot for the code Snippet.  I could create PNG file from PDF with little modifications
( capturing in to BufferedImage bim )

 
But few requirements.

Q1: ImageIOUtil.writeImage() seems to create PNG from PDF file, page by Page, how do we convert
multipage PDF to multipage PNG?
Q2: The out put PNG looks shrinked and very smaller in size. How to preserve the size or can
it be scaled to actual size at client side using java.awt.print?
Q3: Any idea of how much of processing is done for converting PDF to PNG using PDFBox and
how much is left to print with PNG as input using java.awt.print? This will give an idea of
gain in performance by doing PNG conversion at server side and PNG to print at client side

Thanks 

FYI
Printing PDF with PDF took 14 to 20 sec, but this is not good measure as this is to Ms XPS
Creating PNG with PDF as input took 6 to 7 sec
Don't know how much processing is left to print PDF from PNG using Java.awt.print()



Code used
--------- 
private static void writeImageFromPDdocument( PDDocument pDDocument ) throws IOException,
PrinterException {
		
		PDFRenderer pdfRenderer = new PDFRenderer(pDDocument);
		BufferedImage bim = null ;		
		Graphics2D graphics = null ; 
		
		//Change this to your path having input PDF file
		String path = new String ("C:\\Users\\Rangarajan\\Desktop\\Jai GAnesha\\GSoftwares\\PDFBox2.0\\G
Printouts\\" ) ;
	
		
		int pageCounter = 0;
		
		//Below code splits the input PDf file in to PNG file per page, 
		//Have to change the code to append in to single outputStrream having all pages
		for (PDPage page : pDDocument.getPages())
		{ 
			
			System.out.println("Page number = " + pageCounter ) ;
		    try {
	    	
		    	//Below is shrink the page, but need to presrve the actual size or at client side convert
to actual size
		    	bim = pdfRenderer.renderImageWithDPI(pageCounter, 300, ImageType.RGB);
		    	
		    	// graphics can be input to java.awt.print
				//bim = pdfRenderer.renderPageToGraphics(pageCounter, graphics ) ; 
		    
			
		    // suffix in filename will be used as the file format
		    //ImageIOUtil.writeImage(bim, "png" + "-" + (pageCounter++) + ".png", fileOutputStream,
300);
		    FileOutputStream fileOutputStream = new FileOutputStream(new File( path + "FontTest"
+ (pageCounter++) + ".png") );
		    ImageIOUtil.writeImage(bim, "png" , fileOutputStream, 300);			    
		    
		    fileOutputStream.close() ;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}		
	}

> 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
(v6.3.4#6332)

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


Mime
View raw message