I need to implement PDF to jpg conversion function on my website page and support the saving of a PDF document as a thumbnail image.
I have tried several resources, like PDFSharp, but they have not met my expectations. All they can do is to extract the embedded images from PDF file. So, how can I do this? Does anyone know any library that can handle this issue?
This article on XsPDF.com is what you looking for, check out: Export PDF to JPG(s) in C#
Answers
You can try XsPDF's pdf to jpeg conversion function, which support rendering PDF to jpeg images.
Jason Morse has compiled a C# wrapper that can be used as a plugin for the open source imageresizing.net library. If it is an asp.net application, the library allows instant rendering. You can also use the managed API in other application types.
As we all know, Ghostscript is a good solution for rendering PDF. However, the wrapping is more complicated. It maybe not suitable for developers who requires the project be easier.
I found XsPDF sdk somewhere on the web. It works well for my application and provides great pdf to jpeg conversion capabilities. There are detailed steps online and examples are provided for easy start. You may wish to try.
// Create a PDF converter instance by loading a local file PdfImageConverter pdfConverter = new PdfImageConverter("sample.pdf"); for (int i = 0; i < pdfConverter.PageCount; i++) { // Convert each pdf page to jpeg image with original page size //Image pageImage = pdfConverter.PageToImage(i); // Convert pdf to jpg in customized image size Image pageImage = pdfConverter.PageToImage(i, 500, 800); // Save converted image to jpeg format pageImage.Save("Page " + i + ".jpg", ImageFormat.Jpeg); }