Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How do I create thumbnails for pages in PDFs?

Question

How do I create and set thumbnails for pages in PDFs? I know I have to use the SetPageThumbnail function, but I'm not sure how it's done.

Answer

Creating thumbnails for PDFs using Quick PDF Library is simple. Simply use the functions listed in the below order:

Here is some C# sample code demonstrating how this works:

QP.LoadFromFile("original.pdf");
byte[] ImageContent = QP.RenderPageToString(96, 1, 0);
int ImageID = QP.AddImageFromString(ImageContent, 1);
QP.SelectImage(ImageID);
QP.SelectPage(1);
QP.SetPageThumbnail();
QP.SaveToFile("original_with_thumbnail.pdf");

In this sample I've created the thumbnail from the first page in the document and I've set the image of the first page as the thumbnail for the first page, but you could set it as the thumbnail for the second, third, fourth, etc, page.

You could also use a different image, not necessarily one from the same document. This example also works with the image off the disk, instead of in memory. Something like:

int DocID1 = QP.LoadFromFile("thumbnail_source.pdf");
QP.RenderPageToFile(96, 1, 0, "thumbnail.bmp");
QP.RemoveDocument(DocID1);
int DocID2 = QP.NewDocument();
QP.SelectPage(1);
QP.SetOrigin(1);
QP.DrawText(100, 100, "Set page thumbnail test");
int ImageID = QP.AddImageFromFile("thumbnail.bmp", 1);
QP.SelectImage(ImageID);
int r = QP.SetPageThumbnail();
QP.SaveToFile("new_page_with_thumbnail.pdf");

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum