Search code examples
c#pdfpdfsharpmigradoc

Is there a way to calculate Height of the string by provided width with Migradoc/PdfSharp?


i have to render a PDF with 3 columns layout. But i have to know when i dont have enough space for the next paragraph in the column and switch to the next one. I tried to use the XTextFormatterEx what the owner of the library using, but im still don't have accuracy what i need.


Solution

  • PDFsharp: When using XTextFormatterEx to measure text and to draw text, then XTextFormatterEx is the way to calculate the exact height of text strings.

    MigraDoc: With MigraDoc you design documents that can be rendered for several outputs, so at the design stage there are no pages and no "text heights".
    When MigraDoc is used as intended, there is no need to use MeasureString at all.
    MeasureString can be used to determine the height of a single line for PDF, but the height of multi-line paragraphs may still be different.