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

Text in millimeters

Thread ID:

Created:

Updated:

Platform:

Replies:

141296 Dec 5,2018 06:49 AM UTC Dec 6,2018 10:20 AM UTC UWP 1
loading
Tags: Pdf
Jerry Dengu
Asked On December 5, 2018 06:49 AM UTC

Hi i have a document that has to have it's dimensions in millimeters any idea on how i can do that have tried something like below

 recGraphics.DrawString(gNumber.ToString(), recFont, recBrush, new PointF((float)(54* 3.7795275591), (float)(11* 3.7795275591)));
But it's not working , i am working under the assumption that PointF takes dimensions in pixels.

Dilli Babu Nandha Gopal [Syncfusion]
Replied On December 6, 2018 10:20 AM UTC

Hi Jerry,  
  
Thank you for contacting Syncfusion support.  
  
In generally, Essential PDF uses point to draw a graphical object. If your requirement is to draw the graphics element in millimeter, then we have a PdfUnitConverter class to convert the millimeter to point. In this case, we have to convert all the points and size should convert to point before drawing into PDF.   
Please find the code snippet and sample below for your reference.  
Code snippet:   
  
//Initialize PDF document.  
PdfDocument doc = new PdfDocument();  
  
//Add pages to the PDF document.  
PdfPage page = doc.Pages.Add();  
  
//Initialize PdfUnitConverter.  
PdfUnitConvertor converter = new PdfUnitConvertor();  
  
//Convert Millemeter to Point  
float x = converter.ConvertUnits(54, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point);  
float y = converter.ConvertUnits(11, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point);  
  
//Font size.  
float fontSize = converter.ConvertUnits(12f, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point);  
  
//Create PdfFont.  
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, fontSize, PdfFontStyle.Regular);  
  
page.Graphics.DrawString("Hello World", font, PdfBrushes.Black, new PointF(x,y));  
  
//Initialize memorystream  
MemoryStream ms = new MemoryStream();  
//Save the document to stream  
doc.Save(ms);  
  
  
  
  
  
Please let us know whether the provided suggestion fulfills your requirement 
 
Regards, 
Dilli babu. 



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