voyent
Performance converting PDF to TIFF  XML
Forum Index -> ICEpdf General
Author Message
viknesh

Joined: 01/Jul/2012 03:05:32
Messages: 3
Offline


HI,

Basically i'm trying to convert pdf which is stored as a blob field in the database into tiff and at the same time i'm trying to save the pdf in a physical drive. Attached is the code that i'm using to convert the binary data into tiff. The testing that i have done is is converting 30 pdf contain 12 pages and it took me 3 min. I feel it is slow and i would like to further tune to reduce the timing.Below are the spec of my jdk and physical machine. Will multithread program increased the speed??

+can i use the inputStream the same time converting binary to tiff and converting as physical PDF. I'm hitting null pointer when i wanted to convert the binary as a PDF. I don't want to convert the binary stream into PDF and convert from there, i believe it will be time consuming. Below are the code snippets.



File pdfFile = new File(pdf);
FileOutputStream fos = new FileOutputStream(pdfFile);
byte[] buffer = new byte[256];*/

InputStream is = rs.getBinaryStream(3);
byte[] pdfBytes = IOUtils.toByteArray(is);


while (is.read(buffer) > 0) {
fos.write(buffer);
}

fos.close();


JDK : 1.7 Update 5
Memory : 4GB
Spec: Intel I core 5 2.84GHz
ICEpdf: ICEPdf 4.3.2


Any pointer's highly appreciated.




 Filename TiffHelper.java [Disk] Download
 Description
 Filesize 13 Kbytes
 Downloaded:  1464 time(s)

 Filename BlobTest.java [Disk] Download
 Description
 Filesize 3 Kbytes
 Downloaded:  1002 time(s)

patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


The capture times does seem a little slow. The capture process at 1.6 zoom will take a bit longer as the buffer creation time can really add up, but I have to say is quite a bit better in JDK 1.7 then previous releases. You can use multiple threads but you'll want to start each tiffGen.turboConverter() in its own thread. Even with your i5 I probably wouldn't recommend any more then four threads for a ThreadPoolExecutor.


I did a quick review of the code and made some notes listed below.
- to save a little memory in turboConverter() consider remove the image[] in favour of a single BufferedImage and then you can image.dispose() to free up further memory.
- I did some profiling for a client a while ago and if I remember correctly the ImageIO.getImageWritersByFormatName() is fairly expensive. You might want to do this setup only one an reuse the object.


Configuration paramaters and code that might help seed the batch process up.
- The the FontManager is loaded, it scans the system for fonts which can be quite time consuming, consider make the following code to cache the results between runs.

Code:
ResourceBundle messageBundle = ResourceBundle.getBundle(
                 PropertiesManager.DEFAULT_MESSAGE_BUNDLE);
         Properties sysProps = System.getProperties();
         PropertiesManager propertiesManager = new PropertiesManager(sysProps, messageBundle);
         new FontPropertiesManager(propertiesManager, sysProps, messageBundle);
 


- here is a list of system properties that can also help speed up the process.
Code:
         // a few system properties that should be enabled
         Defs.setProperty("java.awt.headless", "true");
         Defs.setProperty("org.icepdf.core.scaleImages", "false");
         Defs.setProperty("org.icepdf.core.paint.disableAlpha", "true");
 
           // set the graphic rendering hints for speed, we loose quite a bit of
           // quality
           // when converting to TIFF, so no point painting with the extra quality
         Defs.setProperty("org.icepdf.core.print.alphaInterpolation",
               "VALUE_ALPHA_INTERPOLATION_SPEED");
         Defs.setProperty("org.icepdf.core.print.antiAliasing",
               "VALUE_ANTIALIAS_OFF");
         Defs.setProperty("org.icepdf.core.print.textAntiAliasing",
               "VALUE_TEXT_ANTIALIAS_OFF");
         Defs.setProperty("org.icepdf.core.print.colorRender",
               "VALUE_COLOR_RENDER_SPEED");
         Defs.setProperty("org.icepdf.core.print.dither", "VALUE_DITHER_DEFAULT");
         Defs.setProperty("org.icepdf.core.print.fractionalmetrics",
               "VALUE_FRACTIONALMETRICS_OFF");
         Defs.setProperty("org.icepdf.core.print.interpolation",
               "VALUE_INTERPOLATION_NEAREST_NEIGHBOR");
         Defs.setProperty("org.icepdf.core.print.render", "VALUE_RENDER_SPEED");
         Defs.setProperty("org.icepdf.core.print.stroke", "VALUE_STROKE_PURE");
 

[Email]
viknesh

Joined: 01/Jul/2012 03:05:32
Messages: 3
Offline


Hi Patrick,
Thanks for the tips really appreciate it. I encounter font problem while converting to TIFF and some of the text is not visible. Attached are the snapshot.








Cheers,
Viknesh
[Thumb - PDF.png]
 Filename PDF.png [Disk] Download
 Description PDF Screenshot
 Filesize 15 Kbytes
 Downloaded:  1041 time(s)

[Thumb - TIFF.png]
 Filename TIFF.png [Disk] Download
 Description TIFF Screenshot
 Filesize 11 Kbytes
 Downloaded:  1041 time(s)

patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


Is it possible to post the original file?
[Email]
a573815

Joined: 06/Sep/2017 02:27:10
Messages: 6
Offline


HI,

I have got stuck in issue.
As suggested by pedrojrivera (http://www.icefaces.org/JForum/posts/list/17504.page )solution ,i am able to convert PDF TO TIFF .But the converted TIFF image having missing image.Its showing as beta in converted TIF (as attached).


Any prompt help is appreciated.

Regards
Abhishek Kaushik
[Thumb - PDF.JPG]
 Filename PDF.JPG [Disk] Download
 Description This is original PDF file,Which i am converting
 Filesize 27 Kbytes
 Downloaded:  894 time(s)

[Thumb - convertedTIFF.JPG]
 Filename convertedTIFF.JPG [Disk] Download
 Description Resultant TIFF with missing image
 Filesize 17 Kbytes
 Downloaded:  909 time(s)

 
Forum Index -> ICEpdf General
Go to:   
Powered by JForum 2.1.7ice © JForum Team