Resize Image in PDF

I am looking at resizing an image (usually a larger PNG image) so that i can save it onto a single page of a PDF. 

With the following code, the png gets distorted and is not true to aspect ratio. How would I resize the image before placing it on a pdf and keep it's aspect ratio. 

            //Drawing image to the PDF page
            if (image.Height > page.Graphics.ClientSize.Height || image.Width > page.Graphics.ClientSize.Width)
            {
                page.Graphics.DrawImage(image, Syncfusion.Drawing.PointF.Empty, (document.Pages[0].GetClientSize()));
                // page.Graphics.DrawImage(image, 0f, 0f, page.GetClientSize().Width, page.GetClientSize().Height);
            }
            else
            {
                page.Graphics.DrawImage(image, new Syncfusion.Drawing.PointF(0, 0));

            }

1 Reply

SL Sowmiya Loganathan Syncfusion Team May 18, 2020 12:13 PM UTC

Hi Amanda,   
 
Thank you for contacting Syncfusion support.   
 
We have analyzed your requirement of “Resize the image and insert it in PDF document” and we have created the sample to achieve this. Please find the download link for the same from below,  
 
 
Please try the above sample in your end and let us know the result. If you face any issue kindly provide us the input image, it will be helpful further analysis and provide the better solution on this.    
 
Regards,  
Sowmiya Loganathan  
 


Loader.
Up arrow icon