try (PDDocument document = PDDocument.load(new File("form.pdf"))) PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); PDField field = acroForm.getField("fullName"); field.setValue("John Doe"); acroForm.flatten(); // Optional: make fields read-only document.save("filled_form.pdf");
document.add(new Paragraph("INVOICE").setBold().setFontSize(20)); Table table = new Table(3); table.addCell("Item"); table.addCell("Quantity"); table.addCell("Price"); table.addCell("Laptop"); table.addCell("2"); table.addCell("$1200"); document.add(table); document.close(); pdf java programming
5.1 Setting Up iText 7 Community <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext7-core</artifactId> <version>7.2.5</version> <type>pom</type> </dependency> 5.2 Creating a Table-based PDF (Invoice) import com.itextpdf.kernel.pdf.*; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.*; public class InvoicePDF public static void main(String[] args) throws Exception PdfWriter writer = new PdfWriter("invoice.pdf"); PdfDocument pdf = new PdfDocument(writer); Document document = new Document(pdf); try (PDDocument document = PDDocument
Compare listings
Compare