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

While creating PDF page from image, full image is not appearing

Hi,

I am trying to create a pdf document with image file. But it seems to be the image is getting cropped. how do i fit the image in pdf page?

here is the code snipet.

pdfDoc.Pages.Add();
PdfImage pdfImage = PdfImage.FromFile(fileAbsolutePath);
PdfPage pdfPage = pdfDoc.Pages[pdfDoc.Pages.Count - 1];
pdfPage.Graphics.DrawImage(pdfImage, new Point(10,30));

Thanks,
Tanmaya

1 Reply

MN Meikanda Nayanar Syncfusion Team September 18, 2013 04:39 AM UTC

Hi Tanmaya,

Please find the code snippet for inserting an image in the Pdf document as below,

PdfDocument document = new PdfDocument();          

PdfPage page = document.Pages.Add();        

PdfImage  img = PdfImage.FromFile(ImageLocation);

PdfPage pdfPage = document.Pages[document.Pages.Count - 1];            page.Graphics.DrawImage(img,0,0,page.GetClientSize().Width,page.GetClientSize().Height);

document.Save("sample.pdf"); 

Please find our online sample in the link below,

http://asp.syncfusion.com/Windows/demos/reporting/pdf/Graphics/Image%20Insertion/Sample.aspx

Please let us know if you have any questions.

Regards,

Meikandan


Loader.
Live Chat Icon For mobile
Up arrow icon