We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PdfConverter performance options consequences

Do you have any documentation that describes how the various CompressionType options affect performance or how the input PDF can affect performance. We've been experimenting on a simple 2 page pdf with the following code:

const string pdfName = "....UnitTests.Aspose.Pdf.Kit.Convert2PagesToTiff.pdf";

var readStream = GetType().Assembly.GetManifestResourceStream(pdfName);

var compressionTypes = new[]

{

CompressionType.CCITT4,

CompressionType.LZW,

CompressionType.RLE,

CompressionType.CCITT3,

CompressionType.None

};

foreach (var compressionType in compressionTypes)

{

var before = DateTime.Now;

var tiffStream = new PdfToTiffConverter(200, compressionType).Execute(readStream);

var secondsElapsed = DateTime.Now.Subtract(before).TotalSeconds;

var tiffFile = new FileInfo(pdfName + "-" + compressionType + ".tiff");

if (tiffFile.Exists)

{

tiffFile.Delete();

}

tiffFile.WriteStream(tiffStream, FileMode.Create, FileAccess.Write);

tiffStream.Dispose();

Debug.Print("-------" + compressionType + "-------" );

Debug.Print(secondsElapsed + " seconds");

// going to create a new FileInfo because I want the most current info

tiffFile = new FileInfo(pdfName + "-" + compressionType + ".tiff");

Debug.Print("file size is " + tiffFile.Length);

}

The PdfToTiffConverter we've written is:

public class PdfToTiffConverter

{

private readonly int _resolution;

private readonly CompressionType _compressionType;

public PdfToTiffConverter() : this(200, CompressionType.CCITT4)

{

}

public PdfToTiffConverter(int resolution, CompressionType compressionType)

{

_resolution = resolution;

_compressionType = compressionType;

}

public Stream Execute(Stream arg)

{

var converter = new PdfConverter

{

Resolution = _resolution,

};

var memoryStream = new MemoryStream();

converter.BindPdf(arg);

converter.DoConvert();

converter.SaveAsTIFF(memoryStream, converter.Resolution, converter.Resolution, _compressionType);

memoryStream.Position = 0;

return memoryStream;

}

public Stream Execute(byte[] arg)

{

var stream = new MemoryStream(arg);

return Execute(stream);

}

}

and what we've found the output is:

-------CCITT4-------
4.5544554 seconds
file size is 29986
-------LZW-------
1.3471347 seconds
file size is 451706
-------RLE-------
4.080408 seconds
file size is 81664
-------CCITT3-------
4.090409 seconds
file size is 54342
-------None-------
1.2711271 seconds
file size is 22458000

Is this what you would expect? What are some other options we should be tweeking. We have some scenarios where we are coverting 50+page PDFs into TIFFs and currently we're using CCITT4 and it takes about 2 minutes.

Hi Kevin,

I’m afraid, it is not feasible to state exact time for processing different types of PDF files, as the PDF files might contain different types of contents and have different structures which might effect the performance. However, it might take 2 seconds or less on average per page; then again, as mentioned earlier it will depend upon the contents and structure of the PDF file. Nevertheless, if you feel like the performance is not up to the mark for some particular files at your end then please share the sample input PDF files along with the code snippet, so we could test it at our end and our team could try to improve the performance for your particular scenarios.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,