empira / PDFsharp-1.5

A .NET library for processing PDF
MIT License
1.28k stars 589 forks source link

Question about using XTextFormatter to print multiple paragraphs #158

Closed SoftCircuits closed 1 year ago

SoftCircuits commented 2 years ago

I found the XTextFormatter class. That's great. It makes it easy to print text 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 it got vertically. 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().

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

TH-Soft commented 2 years ago

Try XTextFormatterEx: https://forum.pdfsharp.net/viewtopic.php?f=8&t=3147

Or XTextFormatterEx2: https://forum.pdfsharp.net/viewtopic.php?f=8&t=3192

XTextFormatter is meant to get you started. Add the features you need.

SoftCircuits commented 2 years ago

@TH-Soft Thanks. I'm happy to tweak the code myself when I have the source.