Questions tagged [pdfptable]

Table class used by iTextPdf (iText and iTextSharp) versions 5.x for generating tables

PdfPTable is the class for creating tables in (Java) and (.Net).

This is a very simple example of its use:

/**
 * Example written by Bruno Lowagie and Nishanthi Grashia in answer to the following question:
 * https://stackoverflow.com/questions/24359321/adding-row-to-a-table-in-pdf-using-itext
 */
@WrapToTest
public class SimpleTable
{
    public static final String DEST = "results/tables/simple_table.pdf";

    public static void main(String[] args) throws IOException, DocumentException
    {
        File file = new File(DEST);
        file.getParentFile().mkdirs();
        new SimpleTable().createPdf(DEST);
    }

    public void createPdf(String dest) throws IOException, DocumentException
    {
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(dest));
        document.open();
        PdfPTable table = new PdfPTable(8);
        for(int aw = 0; aw < 16; aw++)
        {
            table.addCell("hi");
        }
        document.add(table);
        document.close();
    }
}

(101 - a very simple table)

Many more examples illustrating how to build more complex tables, can be found in the examples section of itextpdf.com.

107 questions
0
votes
1 answer

Alter text contents of cells in PdfPTable object

While parsing XML, I get a PdfPTable object. I want to modify text in some of its cells and write it in the end of each page (it should store sums of cells above), but I can't find out how to access particular cell and rewrite text in it? What is…
Anton Zvonovsky
  • 313
  • 2
  • 6
  • 16
0
votes
1 answer

Defining Row span for writeSelectedRows() method

I was trying to add the header for the table by extending PdfPageEventHelper class . so i was trying with onEndPage() . I get the header right but the rowspan attribute doesnt work for the table. I am trying with the code below , PdfPTable table1…
Santhosh
  • 8,181
  • 4
  • 29
  • 56
0
votes
0 answers

how to add a dynamic pdfPtable into field within a existing pdf

I have a pdf template, and I want to insert a dynamic pdfPTable within a specific field, because the table size not always be the same. this is my code: FileOutputStream fileout = new FileOutputStream(filePath); PdfPTable table = new…
user3629362
  • 11
  • 1
  • 4
0
votes
3 answers

Array of PdfPTables[] nullpointer exception when filling

I'm trying to create an Array of tables (2 tables). My program stops on the last line with a nullpointer exception. Any idea why? com.lowagie.text.pdf.PdfPTable[] table = new com.lowagie.text.pdf.PdfPTable[1]; // the cell…
0
votes
1 answer

PdfPcell empty output of Arabic strings

I have that part of code: //Staff // Title font BaseFont titleBf = null; try { titleBf = BaseFont.createFont(BaseFont.TIMES_ROMAN,BaseFont.CP1252, BaseFont.EMBEDDED); } catch (IOException e)…
Houssam Badri
  • 2,441
  • 3
  • 29
  • 60
0
votes
1 answer

PdfPTable.DefaultCell.Padding seems doesn't work

I am trying to define the Padding of a serie of columns that will be pushed inside my PdfPTable... this is my code: PdfPTable table = new PdfPTable(6); table.WidthPercentage = 100; table.SetWidths(new float[]{25, 25, 16, 11, 11,…
Hugo S. Mendes
  • 1,076
  • 11
  • 23
0
votes
1 answer

iText Table with n columns page-break

I am new to iText and am trying to figure something out and ANY help would be greatly appreciated. I would like to generate a table that has n columns that should they not fit on one page, then have the remaining columns continue on the second page…
Kirk
  • 13
  • 4
0
votes
1 answer

itextpdf: how to insert a new page when a table splits?

I'm using iTextPdf 5.4.1. I have a table with many rows in it, and when the table auto-splits to the next page, I want to insert an Image and then another page break to continue the table's rows. For example: say a table will take up 2 pages based…
P Sheldon
  • 43
  • 2
  • 6
0
votes
1 answer

Java iText: text below image

in a PdfPCell i'd like to put multiple images, and a text below each image. i tried with this code: private PdfPTable tabellaRighe() throws BadElementException, MalformedURLException, IOException, DocumentException { int[] cellWidth = {500,…
user1351654
  • 31
  • 2
  • 5
0
votes
1 answer

How to append a table in PDF using iTextsharp without knowing the exact number of pages the table will produce

I'm using iTextSharp to create a PDF and I'm creating multiple tables that run inline in my code. I won't know how long the table is going to be when I fill it with values from my collection. And I don't want one table to run into or through the…
Fus Ro Dah
  • 331
  • 5
  • 22
0
votes
1 answer

How to clip the cell in a PdfPTable with iText?

I am creating a one column PdfPTable given a Rectangle, at a particilar absolute position. In this table, I need to add a collection of PdfPCells and show as much of the cell content as possible and the cells must be clipped at the table rectangle…
Kathy
  • 1
  • 1
0
votes
1 answer

footer text and page numbers in itextsharp

I have a PDF document where, usually, each page is stamped with a footer with a page number preceded by the name of the chapter or section that the page should be in. However, occasionally, I get some large table results that span over a number of…
Dramoth
  • 61
  • 1
  • 6
0
votes
1 answer

Can't find text in PdfTable

BaseFont Vn_Helvetica = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", "Identity-H", BaseFont.EMBEDDED); Font fontNormal = new Font(Vn_Helvetica, 12, Font.NORMAL); foreach (var t in htmlarraylist) { if (t is PdfPTable) …
Alex
  • 8,908
  • 28
  • 103
  • 157
0
votes
2 answers

Set font for all text from Pdfptable with Itextsharp

var htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), styles); document.Open(); BaseFont Vn_Helvetica = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", "Identity-H", BaseFont.EMBEDDED); Font fontNormal = new Font(Vn_Helvetica,…
Alex
  • 8,908
  • 28
  • 103
  • 157
-1
votes
1 answer

How can I display i subscript in pdf using itext5?

I am using unicode character \u1D62(https://unicode-table.com/en/1D62/) to display i subscript but this is not working I have tried using fonts of symbola.ttf file,arial.ttf file ,FreeSans.ttf file and also CardoRegular.otf file but none of the font…
Nikarun
  • 25
  • 1
  • 4