Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Both PDFsharp and PdfSharpCore provide the XTextFormatter class. This class is a lifesaver when it comes to printing blocks that require word wrap.

But here's my question: What if I need to print multiple paragraphs? How can I determine where the bottom of the paragraph just printed is?

XTextFormatter.DrawString() returns void , so it doesn't tell me how far down it got. And there are no overloads that accept a new Y position or rectangle. And the only similar property, LayoutRectangle , simply contains the rectangle that I passed to DrawString() . And XTextFormatter has no MeasureString() method.

So how is it possible to print multiple paragraphs, one just below the previous?

The XTextFormatter class is meant as a sample to get you started. Take the source and adapt it to your needs. An improved version can be found here: forum.pdfsharp.net/viewtopic.php?f=8&t=3192 I liked the old Stack Overflow Jan 24, 2022 at 8:41

The answer is that this is not supported. Surprisingly, the author of the XTextFormatter class chooses not to expose this information and keeps the current Y position internal to that class.

Fortunately, both PDFsharp and PdfSharpCore are open source. You can download the XTextFormatter code and tweak it to your heart's content. Or you can work from the version in this discussion .

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .