PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Calculate the space the text uses on the page
https://forum.pdfsharp.net/viewtopic.php?f=2&t=965
Page 1 of 1

Author:  DeDood [ Tue Dec 01, 2009 7:20 pm ]
Post subject:  Calculate the space the text uses on the page

Hello,

Is there a way to calculate the width and height a text string will have that is created with the XGraphics.DrawString function? I need this so I can calculate how much items (with always a different text length) I can display on one page.

I use the WPF build PDFsharp-MigraDocFoundation-Assemblies-1_30.

Thanks in advance!

Author:  Thomas Hoevel [ Wed Dec 02, 2009 12:10 pm ]
Post subject:  Re: Calculate the space the text uses on the page

Hi!

You can look at the source code of the XTextFormatter class.

See also here:
http://www.pdfsharp.net/wiki/TextLayout-sample.ashx

Or use MigraDoc (handles linebreaks, pagebreaks, headers, footers, page numbers, ...).
http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/