I have a website where a user can view a pdf file which was uploaded to the site and he/she then enters notes about that pdf file into a text field. I would like to give the user the option to export both the pdf file and the notes which they took about that pdf file in a single pdf. How can I go about converting the text to pdf and then appending the notes to the existing pdf format?
Please take a look at this demo: XML Worker.
In this demo, we use an online editor such as TinyMCE. This editor allows you to introduce styles, such as bold, italic,... and so on. The 'text' is sent to the server as simple XHTML. This simple XHTML is converted to PDF using XML Worker.
If you don't need styles, please take a look at this sample from my book. Just enter some text in either one of the text fields and then click the button below the text. The code to do this, is really easy. See the code of the PdfServlet that runs on the server side.
Once you have the PDF with the text created by the end-user, you can merge the original file with the notes using
Of course: maybe you don't want to add the notes as extra pages, but as annotations. In that case, you need the
PdfStamper class and its
I could make the answer to this question much longer, but that's because your question is rather broad. Please be more specific, so that a more specific answer can be given.