import java.io.File; import java.io.IOException;
implementation 'org.apache.pdfbox:pdfbox:2.0.23' java:pdf
/** * Generate a PDF document with a single page containing text. * * @param fileName the output PDF file name * @param text the text to be written in the PDF * @throws IOException if an I/O error occurs */ public void generatePdf(String fileName, String text) throws IOException { // Create a new PDF document try (PDDocument document = new PDDocument()) { // Create a new page PDPage page = new PDPage(); document.addPage(page); import java
// Write text contents.beginText(); contents.newLineAtOffset(100, 700); contents.showText(text); contents.endText(); } // Write text contents.beginText()
import java.io.File; import java.io.IOException;
implementation 'org.apache.pdfbox:pdfbox:2.0.23'
/** * Generate a PDF document with a single page containing text. * * @param fileName the output PDF file name * @param text the text to be written in the PDF * @throws IOException if an I/O error occurs */ public void generatePdf(String fileName, String text) throws IOException { // Create a new PDF document try (PDDocument document = new PDDocument()) { // Create a new page PDPage page = new PDPage(); document.addPage(page);
// Write text contents.beginText(); contents.newLineAtOffset(100, 700); contents.showText(text); contents.endText(); }