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

Measure text length
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4647
Page 1 of 1

Author:  firelex [ Thu Aug 15, 2024 9:22 am ]
Post subject:  Measure text length

Hello all,

I'm creating a pdf document using MigraDoc (package PdfSharp-MigraDoc version 6.1.1).

Document contains several tables. Unfortunately MigraDoc cannot auto-detect the needed column width, so I have to measure every string in every cell.
I've found hier on the forum a solution with XGraphics measuring text width but MigraDoc does not offer a feature to create an XGraphics object containing all current style settings - only PdfSharp does. But I cannot extract a PdfSharp object from my MigraDoc object...

Now the question is: what is the simpliest way to measure text width using current style settings?


Thanks a lot in advance

Author:  Thomas Hoevel [ Thu Aug 15, 2024 11:28 am ]
Post subject:  Re: Measure text length

Maybe try this code:
viewtopic.php?f=8&t=3196

Author:  firelex [ Thu Aug 15, 2024 1:47 pm ]
Post subject:  Re: Measure text length

This was the first solution I've found :D
I hoped there was another way, without transferring all style settings manually. But ok.

Another question: how can I get the amount of free space between left cell border and cell text?

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