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 pdfpage to bitmap (=raster) with given resolution or image size ?

Hi SF & community,

I have a typical pdfpage added via pdfdoc.Pages.Add();
and then populated with syncfusion tools & functions

How can I render that page to bitmap with either a given resolution (ppi) or total image Width/Height size ?

Thanks,
F 

3 Replies

GR Gayathri Ramalingam Syncfusion Team November 30, 2016 02:38 PM UTC

Hi Fabrice, 
 
Thank you for using Syncfusion products. ExportAsImage can be achieved only through the PdfLoadedDocument.  
Method 1: 
The PdfDocument cannot be directly converted to bitmap. The PdfDocument need to be stored in stream and we need to convert the stream as PdfLoadedDocument. And then the pdf can be converted to bitmap. 
 
Please find the sample from the below link, 
 
 
Method 2: 
Please find the code snippet to convert the PDF page to Image using PdfLoadedDocument, 
PdfLoadedDocument doc = new PdfLoadedDocument(@"Barcode.pdf"); 
Bitmap image = doc.ExportAsImage(0, new SizeF(doc.Pages[0].Size.Width, doc.Pages[0].Size.Height), true); 
 
Please find the sample from the below link, 
 

With Regards, 
Gayathri R 



FF fff December 1, 2016 08:36 AM UTC

Hi,

Thanks for that fast & so detailed answer
I will use the methos #1 as I can not save the .pdf to disk in that case

BR & hope it will also help others,
Fabrice


GR Gayathri Ramalingam Syncfusion Team December 2, 2016 09:55 AM UTC

Hi Fabrice 
 
We are glad that the issue is resolved at your end and please let us know if you need further assistance. 
 
With Regards, 
Gayathri R 


Loader.
Live Chat Icon For mobile
Up arrow icon