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

Free Support Forum - aspose.com

Slow thumbnail generation performance for PDF.Kit

To support,

In your documentation, you indicate that to extract a thumbnail image for a given pdf the following code should be used (C#):

var stream = new MemoryStream(file.Data);
var converter = new PdfConverter();

converter.BindPdf(stream);
converter.DoConvert();

var s = new MemoryStream();

while (converter.HasNextImage())
{
converter.GetNextImage(s, ImageFormat.Jpeg);
}

Now this works without issue. A thumbnail image depicting the first page of the PDF is generated; however, since the converter object goes through all of the images contained within a given PDF document, the processing time can be exceptionally long before the thumbnail is ready. Is there a way to speed up this process? Is it necessary that the converter object to loop through all the images in the pdf document to construct the thumbnail, or can I indicate I just want the converter object to read the first page of the pdf only and generate a thumbnail based on that page?

Your feedback would be appreciated.

Cheers

CGB

Hello CGB,

You could do one of the following two things:

1. If you want to generate thumbnail only for the first page, then don't use while loop instead call the GetNextImage method only once. That'll give you the first page thumbnail.

2. And, if you want to generate thumbnails for all the pages, then you'll have to tradeoff with the time consumed on the generation of all the thumnails. However, to make is more user friendly and convenient for the end user, you can use multithreading. Like, instead of generating and showing the thumnails all at once, you can generate and show thumbnails simultaneously.

Now, if you're good at multithreading, I bet you're at advantage :)

Regards

Hi,

PdfConverter class has two properties StartPage and EndPage which can be used to specify the start page and end page of the Pdf file being used to extraction purpose. Once you have called the BindPdf() method, you can set these two properties. For more information please visit PdfConverter Members.