How can convert a page of a pdf to image?

I am working with PdfLoadedDocument class. Now I want to convert certain pages of that document to image. How can I do this?

8 Replies

KE Kathiravan Elangovan Syncfusion Team October 10, 2017 12:18 PM UTC

 
We can export the PDF document pages as images from the PdfLoadedDocument by using the “ExportAsImage” in Windows Forms. We have created the sample to export the pages as images and please refer the sample from the below link. 
 
 
Regards, 
Kathiravan E 



RC Ravi Chandran March 16, 2018 03:06 PM UTC

This is not working with pdf has images in it. Please check the attached pdf file for testing purpose.

Attachment: Files_fbdc5ccf.rar


PE Priyanga Elangovan Syncfusion Team March 19, 2018 10:18 AM UTC

Hi Deb,

We are able to reproduce the issue “PdfLoadedDocument.ExportAsImage API is not working properly while converting the attached PDF document as image”. The reported issue has been resolved while using the PdfViewerControl.ExportAsImage API with Pdfium rendering engine. We have integrated Pdfium rendering engine into our PDF viewer control and it is available from Essential studio Volume 1 2018 release, in which the reported issue has been resolved. Kindly upgrade to our latest 16.1.0.24 version to get the issue resolved and it is available for download under the following link.

https://www.syncfusion.com/forums/136049/essential-studio-2018-volume-1-release-v16-1-0-24-is-available-for-download

Please find the KB illustrating how to use Pdfium with PdfViewer for your reference in the following link.

https://www.syncfusion.com/kb/8569/how-to-use-pdfium-rendering-engine-in-syncfusion-pdf-viewer-for-wf

Kindly use the PdfViewerControl.ExportAsImage API to get this issue resolved. We have prepared the sample for your reference. Please find the sample from below link.
 

http://www.syncfusion.com/downloads/support/forum/133120/ze/WF-1491892953.zip

Regards,
Priyanga.E



SE Sinoheh Enayati replied to Priyanga Elangovan June 10, 2018 07:44 AM UTC

Hi Deb,

We are able to reproduce the issue “PdfLoadedDocument.ExportAsImage API is not working properly while converting the attached PDF document as image”. The reported issue has been resolved while using the PdfViewerControl.ExportAsImage API with Pdfium rendering engine. We have integrated Pdfium rendering engine into our PDF viewer control and it is available from Essential studio Volume 1 2018 release, in which the reported issue has been resolved. Kindly upgrade to our latest 16.1.0.24 version to get the issue resolved and it is available for download under the following link.

https://www.syncfusion.com/forums/136049/essential-studio-2018-volume-1-release-v16-1-0-24-is-available-for-download

Please find the KB illustrating how to use Pdfium with PdfViewer for your reference in the following link.

https://www.syncfusion.com/kb/8569/how-to-use-pdfium-rendering-engine-in-syncfusion-pdf-viewer-for-wf

Kindly use the PdfViewerControl.ExportAsImage API to get this issue resolved. We have prepared the sample for your reference. Please find the sample from below link.
 

http://www.syncfusion.com/downloads/support/forum/133120/ze/WF-1491892953.zip

Regards,
Priyanga.E


I used "PdfLoadedDocument" latest version in my project.
The exported page work fine in IIS-Express and visual studio debugging mode but not work in release mode on IIS.
My iis server is Windows server 2016.
The exported page do not have any image or some text.
My code:

pdfDocument.Save(stream);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream);
                for (int i = 0; i < pageNumber; i++)
                {
                    using (var photoStream = new MemoryStream())
                    {
                        using (Image image = loadedDocument.ExportAsImage(i))
                        {
                            image.Save(photoStream, System.Drawing.Imaging.ImageFormat.Bmp);
                        }
                    }
                }

Attachment: Sample_8db62166.rar


PE Priyanga Elangovan Syncfusion Team June 11, 2018 12:53 PM UTC

Hi Sinoheh,

Currently we are working on creating the environment with the provided OS details to reproduce the issue at our end. We will update you the details as soon as possible.

Regards,
Priyanga.E
 



PE Priyanga Elangovan Syncfusion Team June 14, 2018 12:38 PM UTC

Hi Sinoheh,

We are unable to reproduce the issue “some of the text and images are missing while exporting the pages into images using ExportAsImage API” with windows server 2016 and Visual studio 2015 in release mode. We have prepared the sample by using the provided code snippet and the input PDF document. Please find the sample from below link.

http://www.syncfusion.com/downloads/support/forum/133120/ze/ExportAsImage366051463

We have created a support incident under your account to track and provide a solution for this issue. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Regards,
Priyanga.E
 



SK Soeren Kuklau replied to Priyanga Elangovan August 6, 2018 11:58 AM UTC

Hi Sinoheh,

We are unable to reproduce the issue “some of the text and images are missing while exporting the pages into images using ExportAsImage API” with windows server 2016 and Visual studio 2015 in release mode. We have prepared the sample by using the provided code snippet and the input PDF document. Please find the sample from below link.

http://www.syncfusion.com/downloads/support/forum/133120/ze/ExportAsImage366051463

We have created a support incident under your account to track and provide a solution for this issue. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Regards,
Priyanga.E
 


Slightly off-topic, but:

We are able to reproduce the issue “PdfLoadedDocument.ExportAsImage API is not working properly while converting the attached PDF document as image”. The reported issue has been resolved while using the PdfViewerControl.ExportAsImage API with Pdfium rendering engine.

Can I set the rendering engine while not using a PdfViewer? In the following code snippet, I don't have a PDF viewer at all (I'm only referencing the Syncfusion.Web.FileFormatsBase NuGet package):

    var doc = new Syncfusion.Pdf.Parsing.PdfLoadedDocument(elFile.FileContents);

    bmp = doc.ExportAsImage(0, 0, new SizeF(previewSize, previewSize), 300f, 300f, true).FirstOrDefault();

There doesn't appear to be a way to set a rendering engine for the export (e.g., a new overload or a new property on ImageExportSettings).


GR Gangagowri Rajendran Syncfusion Team August 7, 2018 12:18 PM UTC

Hi Sinoheh, 
 
We support “Pdfium” rendering engine only in PDF viewer. We do not have support in PdfLoadedDocument, PDF viewer control can be used to export pages of the PDF document as images without bringing it to the view. Please refer to the UG documentation below. 
 
 
Regards, 
Gangagowri Rajendran 


Loader.
Up arrow icon