We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Render PDF Page to Image

Hi, 

how can i get a 

List<Bitmap> images = new List<Bitmap>(); 

from the pages of a pdf document? 

I found your solution on  PDF to Image conversion in Azure functions | ASP.NET Core - PDF Viewer (syncfusion.com) but for net.core console apps seems not the right way. 



3 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team February 8, 2023 12:06 PM UTC

Please refer to the below UG documentation to export the PDF document as pages:

https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/how-to/export-as-image#export-as-image-in-aspnet-core-60

code sample:

//Uses the Syncfusion.EJ2.PdfViewer assembly

PdfRenderer pdfExportImage = new PdfRenderer();

//Loads the PDF document

pdfExportImage.Load(@"currentDirectory\..\..\..\..\Data\HTTP Succinctly.pdf");

//Exports the PDF document pages into images

Bitmap bitmapimage = pdfExportImage.ExportAsImage(0);

//Save the exported image in disk

bitmapimage.Save(@"currentDirectory\..\..\..\..\Images\" + "bitmapImage" + i.ToString() + ".png");


We have attached a sample to achieve your requirement on your end. Please try this on your end and let us know the result.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Export_as_image_-_skia_sharp_(1)-2278581







PE Peter February 8, 2023 01:59 PM UTC

Hi 

thx for your response.


Same problem on your code sample: 

I need a Bitmap Object but on this line 


Bitmap bitmapimage = pdfExportImage.ExportAsImage(0);

the result is a SKBitmap and not a System.Drawing.Bitmap, 






CK Chinnamunia Karthik Chinna Thambi Syncfusion Team February 10, 2023 05:28 AM UTC

.NET 6 standards have support for System. Drawing only in Windows platform. So, we have migrated to the Skaisharp for .Net 6 and above. If your .NET Version is below 6.0, then you can make use of this code.

 

 

//Uses the Syncfusion.EJ2.PdfViewer assembly

PdfRenderer pdfExportImage = new PdfRenderer();

//Loads the PDF document

pdfExportImage.Load(@"currentDirectory\..\..\..\..\Data\HTTP Succinctly.pdf");

//Exports the PDF document pages into images

Bitmap bitmapimage = pdfExportImage.ExportAsImage(0);

//Save the exported image in disk

bitmapimage.Save(@"currentDirectory\..\..\..\..\Images\" + "bitmapImage" + i.ToString() + ".png");


Loader.
Live Chat Icon For mobile
Up arrow icon