0

This is my code

        // Create table for seller and buyer information
        Table table = new Table(UnitValue.createPercentArray(new float[]{50, 50}));
        table.setWidth(UnitValue.createPercentValue(100));
                    

        // Add seller and buyer information
        table.addCell(new Cell().add(new        Paragraph("Seller:")).setBorder(Border.NO_BORDER).setPadding(5).setBorderRight(new SolidBorder(1)));
        table.addCell(new Cell().add(new Paragraph("Buyer:")).setBorder(Border.NO_BORDER).setPadding(5).setBorder(Border.NO_BORDER).setBorderLeft(new SolidBorder(1)));

        table.addCell(new Cell().add(new Paragraph("XYZ Pvt. Ltd.\nNew Delhi, India\nGSTIN: 29AABBCCDD121ZD")).setBorder(Border.NO_BORDER).setPadding(5).setBorderRight(new SolidBorder(1)));
        table.addCell(new Cell().add(new Paragraph("Vedant Computers\nNew Delhi, India\nGSTIN: 29AABBCCDD131ZD")).setBorder(Border.NO_BORDER).setPadding(5).setBorder(Border.NO_BORDER).setBorderLeft(new SolidBorder(1)));
        
        // Add vertical line between columns
        table.addCell(new Cell().setBorder(Border.NO_BORDER));
        table.setBorder(new SolidBorder(1));
        // Add the seller and buyer information table to the document
        document.add(table);

        // Add items information
        Table itemsTable = new Table(UnitValue.createPercentArray(new float[]{25, 25, 25, 25}));
        itemsTable.setWidth(UnitValue.createPercentValue(100));
        itemsTable.setBorder(new SolidBorder(1));
        

        // Add table headers
        itemsTable.addCell(new Paragraph("Item").setTextAlignment(TextAlignment.CENTER));
        itemsTable.addCell(new Paragraph("Quantity").setTextAlignment(TextAlignment.CENTER));
        itemsTable.addCell(new Paragraph("Rate").setTextAlignment(TextAlignment.CENTER));
        itemsTable.addCell(new Paragraph("Amount").setTextAlignment(TextAlignment.CENTER));

        // Add table data
        itemsTable.addCell("Product 1");
        itemsTable.setTextAlignment(TextAlignment.CENTER);
        itemsTable.addCell("12 Nos");
        itemsTable.setTextAlignment(TextAlignment.CENTER);
        itemsTable.addCell("123.00");
        itemsTable.setTextAlignment(TextAlignment.CENTER);
        itemsTable.addCell("1476.00");
        itemsTable.setTextAlignment(TextAlignment.CENTER);

        document.add(itemsTable);

enter image description here The above image is the pdf generated which has the invoice. The live does not touch the border. Can someone please help? I tried everything but nothing helped.

  • Please read the tag descriptions before you use the tags. The API tag starts with: _"DO NOT USE."_ – jabaa Mar 01 '23 at 15:01
  • From what library are those `Table`, `Paragraph`, `Cell`, ... classes? That is not something from Spring Boot or Thymeleaf AFAIK. – Wim Deblauwe Mar 03 '23 at 15:22

0 Answers0