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:
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.
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.
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 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.
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.