I am using the XsPDF library to create a new PDF. The function I want to perform now is to draw text on the PDF page, and I need to know the text height of each line. In my test, i can deal with text in one line. But when it comes a paragraph that has multiple lines of text, I don't know how to control the height of text, and how many lines there will be. Please suggest!
This article on XsPDF.com is what you looking for, check out: Add long text on PDF in C#.
Answers
I also encountered the same problem. I've been working around this issue for about four days. I used the XGraphics.DrawString() method directly, but it didn't work as expected. It seems that I can't use LayoutRectangle, but have to manually manage the text to fit within the desired area. Am I missing something here?
Do you mean to add long text/paragraph on PDF document and control the height of text? If so, do not worry. XsPDF PDF to Text SDK provides you with C# methods for creating a rectangle to render long text in PDF. You only need to set the rectangle x, y and width. The height will be measured by XTextFormatter object automatically. So you can input any value of height, here we set to 0.
I shall take an eye out this. I will let you know my progress so that it may help others too.
Thanks for the tip! It is worked. Really appreciated!