Page numbersĭocument.ShowTextAligned(new Paragraph(Stringįollowing is the complete code listing. Adding Page NumbersĪdd Page numbers at the top right corner of the page, as shown in Figure 10. SetItalic().SetFontColor(ColorConstants.BLUE))įigure 9: Adding a hyperlink G. ![]() Paragraph hyperLink = new Paragraph("Please ") Creating a HyperlinkĬreate a Hyperlink and add it to the document (see Figure 9). Creating a TableĬreate a Table and add it to the document, as shown in Figure 8. Adding an ImageĪdd an Image to the PDF document by using an Image instance (see Figure 7). LineSeparator ls = new LineSeparator(new SolidLine()) įigure 6: Creating the separator line D. Adding a Horizontal Separator LineĪdd a horizontal line using Line Separator. Paragraph subheader = new Paragraph("SUB HEADER")įigure 5: Creating the Sub Header C. Add this Sub Header to the document object, as shown in Figure 5. Creating a Sub HeaderĬreate a Sub Header with text alignment center and set the font size to 15. Figure 4 is the image of a PDF document with header text.įigure 4: Showing the header text B. Run the program and go to the path specified in PdfWriter and open the PDF document. Paragraph header = new paragraph("HEADER") PdfDocument pdf = new PdfDocument(writer) PdfWriter writer = new PdfWriter("C:\\demo.pdf") Must have write permissions to the path folder Finally, we need to close the document object by calling the Close() method. Following is the code snippet to create a paragraph object and add it to the document object. We can achieve this by creating a paragraph object. Header Content is center aligned to the document and I set the font size to 20. Adding a HeaderĪdd a header to the PDF document. ![]() I will add a Header, SubHeader, Line Separator, Image, Table, Hyperlink, and finally page numbers to the PDF document.
0 Comments
Leave a Reply. |