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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

111233 Sep 13,2013 04:22 AM Sep 18,2013 12:39 AM Windows Forms 1
loading
Tags: PdfViewer
Tanmaya Mohanty
Asked On September 13, 2013 04:22 AM

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

Meikanda Nayanar [Syncfusion]
Replied On September 18, 2013 12:39 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;