简体   繁体   中英

Get text width from font migradoc / pdsharp for table columns

I want to create a table in a PDF document which would have variable width of columns depending on the width of its contents.

I am using PDFSharp, MigraDoc

Maybe getting the paragraph width from the individual cells will help. Is there a way to get text width depending on the font / styles?

Any clues?

Thanks.

Using PDFsharp functions, you can get the width of any text.
MigraDoc is not limited to PDF, it creates documents for PDF, RTF, print. No chance to determine the exact width (unless you restrict yourself to PDF and use PDFsharp to get the width).
MigraDoc will break text in columns to the next line when needed.

Create a dummy PdfDocument, create a page, get an XGraphics object (gfx) for that page, then use gfx.MeasureString() to find the width.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM