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

Free Support Forum - aspose.com

PDF to image rendering performance at low resolutions

I'm trying to use PdfConverter to create thumbnails for pages of PDFs. The rendering performance is proportional to the resolution, but it is still slow at low resolutions. This table compares resolution vs. time for rendering the first page of a relatively complex PDF:

DPI     Time
50	0.874
100	0.982
150	1.089
200	1.218
250	1.331
300	1.531

There seems to be a base time of ~0.8 seconds (for this PDF) even if I render to a 10x10 px image. Is there anything I can do to make this faster? I am willing to sacrifice image quality (it's just a thumbnail), but outputting as jpeg with low quality has little impact on performance.

Hi S4i,

Thanks for using our products.

Can you please share some details regarding sample source code and template documents you are using or create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

It doesn't matter which PDF you use, but I attached the one I used.

static void Main(string[] args)
{
Test(); // warm up
Test();
Test();
Console.ReadKey();
}

static void Test()
{
for (int resolution = 50; resolution <= 300; resolution += 50)
{
var outputFile = string.Format("output-{0}.png", resolution);
using (new Tracer(resolution.ToString(CultureInfo.InvariantCulture)))
{
Render("input.pdf", outputFile, resolution, ImageFormat.Png);
}
}
Console.WriteLine();
}

static void Render(string inputFile, string outputFile, int resolution, ImageFormat fmt)
{
var conv = new PdfConverter();
conv.BindPdf(inputFile);
conv.Resolution = new Resolution(resolution);
conv.StartPage = 1;
conv.EndPage = 1;
conv.DoConvert();
if (!conv.HasNextImage())
throw new InvalidOperationException("Failed to render");

conv.GetNextImage(outputFile, fmt);
}

public class Tracer : IDisposable
{
readonly string _message;
readonly DateTime _before;

public Tracer(string message)
{
_message = message;
_before = DateTime.UtcNow;
}

public void Dispose()
{
var after = DateTime.UtcNow;
var diff = after - _before;
Console.WriteLine("{0} ({1} seconds)", _message, diff.TotalSeconds);
}
}

Upon further testing, rendering is quite fast for some simple PDFs. However it is still slow for the PDF I attached - even rendering at 1 DPI to an 8x11 px image takes almost a second. I think this happens when the PDFs have embedded images.

Hi S4i,

Thanks for sharing the details. I tested the scenario using your sample code and provided PDF document and noticed that the file is working fine, not having any problem. Full page PNG image format file is available within 2 seconds after complete processing. I think this is quite a normal time for this size of image.

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,