/ Published in: Java
Creates a new document with a single page and adds text to it.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * @param args the command line arguments * @throws java.io.IOException */ PDDocument document = new PDDocument(); PDPage page = new PDPage(PDRectangle.A4); document.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(document, page); contentStream.beginText(); contentStream.setFont(PDType1Font.TIMES_ROMAN, 12); contentStream.newLineAtOffset(25, 500); contentStream.showText("Hello World"); contentStream.endText(); contentStream.close(); document.save(""); document.close(); }