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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Scale vector image

Thread ID:

Created:

Updated:

Platform:

Replies:

148537 Oct 24,2019 07:29 AM UTC Oct 25,2019 09:11 AM UTC WPF 1
loading
Tags: PDF
Jef
Asked On October 24, 2019 07:29 AM UTC

Hi,

I want to insert a vector image in a pdf file but instead of using the original resolution I want to scale it down to a different size. I have this code based on the documentation.

PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfGraphics graphics = page.Graphics;

PdfMetafile metaChart = new PdfMetafile("BoxOk.emf");

PointF drawingCoordinates = new PointF(0, 0);

metaChart.Draw(page, new RectangleF(drawingCoordinates.X, drawingCoordinates.Y + 2, 12, 12));

doc.Save("Output.pdf");
doc.Close(true);

The result however is a 51 page pdf with a small 12 by 12 part of the image on each page. What I need is the complete image scaled down to 12 by 12 only on the first page.

How can this be achieved?

Attachment: Pdf_and_vector_image_42004542.zip

Prakash Viswanathan [Syncfusion]
Replied On October 25, 2019 09:11 AM UTC

Hi Bruno, 
 
Thank you for contacting Syncfusion support.  
 
We have prepared a sample to draw the vector image with the provided size, please find the sample from below mentioned link.  
 
Refer the below modified code snippet, 
 
// Create a PDF Document. 
PdfDocument doc = new PdfDocument(); 
//Add pages to the document 
PdfPage page = doc.Pages.Add(); 
//Create PDF graphics for the page 
PdfGraphics graphics = page.Graphics; 
//Create a Metafile instance 
PdfMetafile metaChart = new PdfMetafile(DataPathBase + "BoxOk.emf"); 
RectangleF rect = new RectangleF(0, 2, 12, 12); 
//Draw the Metafile in the page         
graphics.DrawImage(metaChart, rect); 
//Save and close the document 
doc.Save("Sample.pdf"); 
doc.Close(); 
 
Please let us know if you need any further assistance on this.  
 
Regards, 
Prakash V 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon