Click here to Skip to main content
15,885,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
How to measure the string size in WPF..In C1PdfDocument(component1PDF)have a function MeasureString(string,Font) to measure width/height of string do WPF has similar function.

internal float GetWidth(string text,Font font) {
     C1PdfDocument pdf;
     return pdf.MeasureString(text,font).Width;
   }

Regards,
sajith
Posted
Updated 28-Jan-12 20:45pm
v3

1 solution

This is done using the class System.Windows.Media.FormattedText, please see: http://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.aspx[^].

Also, see the code sample in this discussion: http://stackoverflow.com/questions/824281/wpf-equivalent-to-textrenderer[^].

—SA
 
Share this answer
 
Comments
Amir Mahfoozi 29-Jan-12 2:53am    
+5
Sergey Alexandrovich Kryukov 29-Jan-12 3:09am    
Thank you, Amir.
--SA
sajithnet 29-Jan-12 3:16am    
Many thanks SAKryukov
Sergey Alexandrovich Kryukov 29-Jan-12 3:38am    
No problem at all.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900