Write text directly to a PDF document

Write text directly to a PDF document

Forum member · Jan 12, 2009
I am a newbee to Dynamic PDF generator for Java Can anybody tell me how to write raw string messages to PDF document and render it. I saw HelloWorld examples written to a label element added to a page and the rendered in a PDF document Can I also know how to use the operatorWriter, PrintWriter and DocumentWriter objects Thanks in Advance Asokan S

Re: Write text directly to a PDF document

Support · Jan 12, 2009
Hello Asokan, What exactly you mean by writing strin messages to PDF? Do you want to add text to the PDF or you want to display an alert (message box) when opening a PDF. If you want to add text to the PDF then you can do this by using the Label element shown in the HelloWorld example. If you want to display any message boxes then you can use the JavaScript. You can add JavaScript to the PDF using the DocumentJavaScript class. The PageWriter, DocumentWriter classes will be used to create custom page elements by extending the existing page elements. These classes will provide some properties to write the PDF operators. You can refer to the Extending The Object Model and Custom Page Elements topics on our help documentation. You can also refer to the Members of the PageWriter class on our help documentation. Thanks, ceTe Software Support Team.

Re: Write text directly to a PDF document

Forum member · Jan 12, 2009
Hello Team Thanks for the prompt reply. Let me put out my question clear. In the Helloworld.java, the portion of code // Create a Label to add to the page String strText = "Hello World...\nFrom DynamicPDF Generator for Java\nDynamicPDF.com"; Label objLabel = new Label(strText, 0, 0, 504, 100, Font.getHelvetica(), 18, TextAlign.CENTER); // Add label to page objPage.getElements().add(objLabel); Assuming the label is inside a table cell this code may be equilvalent in HTML as <table> <tr><td> <label name='objLabel'> Hello World...\nFrom </label> </td></tr> </table> My question is will there be any way to add text without adding the label object Something equivalent to <tr><td> Hello World...\nFrom ... </td></tr> is there any api like writer.writeText("HelloWorld", 0, 0, Font.getHelvetica(), 18, TextAlign.CENTER); Our intention is to create a simple template creation helper using HTML(similar) tags. To render a text, is it always a necessity to add a label and display the text.

Re: Write text directly to a PDF document

Support · Jan 13, 2009
Hello Asokan, Yes, in order to add text to the PDF you will have to use the Label page element. You will have to use any of our page elements to add data to the PDF document. If you want to add HTML text then you will have to use the FormattedTextArea element which takes the HTML text. You can refer to the Help Documentation for the supported HTML tags . If you want to add a table to the PDF then you can use the Table page element. You can add columns and Rows to the table. The cells can take the string to display the text directly without using the Label object. You can also add any page element to the cell of a table. Thanks, ceTe Software Support Team.

Re: Write text directly to a PDF document

Forum member · Jan 13, 2009
Thank you for the clear reply.