Can I add paragraphs with SharpPDF, without having to specify the exact coordinates? Can’t I just place paragraphs one under the other?
Please tell me if you used the library.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not possible to just add paragraphs one after another without specifying coordinates, however I did write this sample which will move the paragraphs down the page and create a new page when necessary. In this want you could write out text, paragraphs, drawing, and always know the position of the “cursor.”
The Y is backwards in this API, so 792 is the TOP and 0 is the BOTTOM. I use a Graphics object to measure the height of the string, since the Graphics is in pixels and the Pdf is in points I do an estimation to make them similar. I then subtract the height from my remaining Y value.
In this example I keep adding
paragraph1andparagraph2over and over, updating my Y position as I go along. When I get to the bottom of the page I create a new page and reset my Y position.This project hasn’t seen any updates for a number of years, but the source code is available, using something similar to what I’ve done you could make your own function that allows you to successively add paragraphs which will keep track of a CURSOR position of where it thinks something should go next.