PDF to Tiff conversion is Slow

When converting PDFs to TIFF, the process seems very slow.

Pretty simple code:

public void convertFile() {
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); 
	String dateStart = "";
	String dateStop = "";
	Date d1 = null;
	Date d2 = null;
	

	dateStart = sdf.format(new Date());
	OutputStream imageStream = null;
	Document pdfDocument;

	Resolution resolution = new Resolution(200);
	
	TiffSettings tiffSettings = new TiffSettings();
    tiffSettings.setCompression(CompressionType.CCITT4);
	tiffSettings.setDepth(ColorDepth.Format8bpp);
	tiffSettings.setSkipBlankPages(true);
	
	TiffDevice tiffDevice;
	tiffDevice = new TiffDevice(resolution, tiffSettings);
	
	try {
                
                File inFile= new File(inputFilePath);
                System.out.println(inFile.getName());
                
		File file = new File(inputFilePath+"/");
		File[] files = file.listFiles();
		
		for(File f: files){
            System.out.println(f.getName());

            pdfDocument = new Document(inputFilePath+"/"+f.getName());
          
              imageStream = new FileOutputStream(outputFilePath+f.getName()+".tiff");	
            
            
                tiffDevice.process(pdfDocument, imageStream);
                imageStream.close();		
                           
        }// End For
		
		dateStop = sdf.format(new Date());
		d1 = sdf.parse(dateStart);
		d2 = sdf.parse(dateStop);
		long diff = d2.getTime() - d1.getTime();
		long diffSeconds = diff / 1000 % 60;
		long diffMinutes = diff / (60 * 1000) % 60;
		System.out.println(diffMinutes + " mins, "+ diffSeconds + " secs.");
	} catch (FileNotFoundException e1) {
		e1.printStackTrace();
	}
	catch (IOException e) {
		e.printStackTrace();
	} catch (ParseException e) {
		e.printStackTrace();
	}
}		

Works fine, just very slow. A 5-6 page PDF takes 20 seconds, consistently. A group of 104 PDFs took 33 minutes to convert.

By comparison, a command line utility (low cost…not much support) converted the same 104 files in just over 3 minutes.

At the moment Java 8 and aspose.pdf-18.9-java

@bduanebcbsma

Thank you for contacting support.

Would you please share a sample file which consumes a lot of time during the process so that we may try to reproduce and investigate it in our environment. Also share your environment details and information about command line utility that you are referring to. Before sharing requested data, please ensure using Aspose.PDF for Java 19.3.

I am using Aspose PDF for Java 19.3
JDK 1.8

Windows 7 Enterprise SP1
8GB ram
Intel Core i7-5600U CPU @ 2.60GHz
Rollup Invoice Template v11.pdf (376.7 KB)

Please notice that the attached PDF is not unique in being slow to process. My results are consistent in that what I put together is significantly slower than other utilities.
thanks

@bduanebcbsma

Thank you for sharing requested data.

We have noticed the TIFF to be generated within 10 seconds where loading of Document Object Model (DOM) of Aspose.PDF for Java API and allocation of resources is also included in this time span. Therefore, consumption of 10 seconds does not appear that problematic for this case. Feel free to share your comments so that we may take care of your concerns.

Well, on the surface 10 (20 in my environment) seconds does not seem like a lot of time. But it is only a 6 page document. Using other utilities, this same PDF is converted in a blink of the eye.

The issue really comes to light when converting a larger volume of small documents or a larger document. Consider that converting 104 small (5-6 page) documents took 33 minutes using the utility I put together using Aspose, but only 3 minutes using a different utility (not easily supported).

Also, the 156 page document I attached took 23 seconds using the other utility, but takes 8min 55 sec using the Aspose based utility.

Is there something that my simple code is doing that is making this slow, or is this just the nature of Aspose PDF for Java. Is there some different approach I could take?

We have a need to convert a significant volume of pages of PDF to Tiff and are concerned about the time it takes to convert as few as 100 pages.

Direct Pay v10d - Medicare Advantage_1_2.pdf (3.3 MB)

@bduanebcbsma

We are able to convert attached PDF document of 156 pages to a TIFF image within 2 minutes and 53 seconds on an i5 processor and 8GB memory. However, would you please share some details about other utilities you are referring to so that we may log your concerns and investigate further.

The utility is simply called PDFtoTiff and is on a site run by digitzone.com. I simply used that as a reference.

But can we focus more on your results please? You have success converting the same file in just about 3 minutes. My results were more 33 minutes for the same conversion. That is a significant difference.

Of course simply comparing the i5 to the i7 is not really simple. But I would generally expect better results from the i7 (had to tell not knowing processor speed, cores, etc).

I am using jdk1.8.0_181, pretty much as-is. Although I am an experienced developer, I do not have a lot of experience with the details of Java. Could there be something in the java setup I have neglected?

I welcome your thoughts

@bduanebcbsma

Thank you for the information.

We have logged an investigation ticket with ID PDFJAVA-38503 in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will be informed as soon as any update is available.

We have recorded information about third party utility for comparisons while investigating this ticket in detail at our end. We too expect better results form i7 processor, in general.

Moreover, please make sure that you do not have small value set for maximum memory allocation pool for the Java virtual machine. Please try to set bigger value for Xmx parameter at your end if that helps, otherwise any special settings are not required for performance improvements.

We are sorry for the inconvenience.

Just wondering if any progress has been made on this item?

Thanks you,
Brian

@bduanebcbsma

Thank you for getting back to us.

We are afraid this ticket is currently pending owing to previously logged tickets and may take some time before it is scheduled. We will let you know as soon as any significant progress will be made in this regard.