iText is a free and open source library for creating and manipulating
PDF documents in Java. The following example shows adding a Chunk to PDF document
which is the smallest unit of text that can be added to a PDF.
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, new FileOutputStream("test22.pdf"));
//Open the document before adding any content
document.open();
Paragraph paragraph = new Paragraph("BE THE CODER");
paragraph.add("\n"); //new line
//the smallest significant part of text that can be added to a document
Chunk chunk = new Chunk("be the coder",
FontFactory.getFont(FontFactory.COURIER, 16,
Font.ITALIC, BaseColor.BLUE));
chunk.setBackground(BaseColor.YELLOW);