Free Support Forum - aspose.com

Diff types of Compession Type

Hi Can you please let me know the difference between below compression types, and which is better for performance wise as we are experiencing performance issue while converting pdf to image. Also let me know how to improve the performance of converting from pdf to image.

1.LZW
2.CCITT4
3.CCITT3
4 RLE
5.None.

please find below my code.

if (File.Exists(configpdfPath))
{
Aspose.Pdf.Document pdf = new Document(configpdfPath);
var page = pdf.Pages[1];
mypdf.Pages[pageNumber].PageInfo.Height = page.PageInfo.Height;
using (PdfConverter pdfconverter = new PdfConverter())
{
pdfconverter.Resolution = new Aspose.Pdf.Devices.Resolution(200);
pdfconverter.BindPdf(configpdfPath);
pdfconverter.DoConvert();
using (MemoryStream ms = new MemoryStream())
{
var stopwatch1 = Stopwatch.StartNew();
string methodName1 = " Configuration Performance method";
pdfconverter.SaveAsTIFF(ms, Aspose.Pdf.Devices.CompressionType.LZW);
stopwatch1.Stop();
PerfomanceProfiler.LogExecTime(this.GetType().Name, methodName1, stopwatch.ElapsedMilliseconds.ToString());
pdfconverter.Close();
using (System.Drawing.Bitmap bitmapImg = new System.Drawing.Bitmap(ms))
{
Stream img = ConvertImage(bitmapImg);
Image fragmentHeaderImage = new Image();
fragmentHeaderImage.ImageStream = img;
fragmentHeaderImage.FixHeight = page.PageInfo.Height;
fragmentHeaderImage.FixWidth = 900;
mypdf.Pages[pageNumber].Paragraphs.Add(fragmentHeaderImage);
}
}
}
}

@yahi

Thank you for contacting support.

We would like to update you that you can find description of CompressionType enumeration in API references where CCITT3 and CCITT4 creates Black and White TIFF images; LZW can be used in combination with Depth property to generate grayscale TIFF image. RLE is useful on data that contains many runs, for example simple graphic images. More detailed performance can be compared with Stopwatch class as in the code snippet shared by you.

Moreover, please use recommended Document Object Model (DOM) approach to create TIFF images instead of old Facades approach. DOM approach has been explained in Convert PDF Pages to TIFF Image.

We hope this will improve performance when tested with latest version of the API. If you still notice slower rendering, then please share your source PDF file while mentioning time consumption details so that we may investigate further to help you out.

Hi,

The given suggestion by you i have implemented but not giving much performance. See is there any other way other than SaveAsTIFF() method like compressing the pdf without converting to image.

@yahi

Would you please share source and generated files along with the code snippet, while mentioning the time consumed during the process so that we may try to reproduce and investigate performance problems in our environment.