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
22
votes
4 answers

how to set width for PdfPCell in ItextSharp

i want set width for PdfpCell in Table, i want design this i Write this code PdfPCell cell; PdfGrid tableHeader; PdfGrid tmpTable; PdfGrid table = new PdfGrid(numColumns: 1) { WidthPercentage = 100,…
Pouya
  • 1,908
  • 17
  • 56
  • 78
17
votes
1 answer

How can I repeat the headers of an iTextSharp PdfPTable on each page?

How can I get iTextSharp to repeat the headers of a PdfPTable on each page of the generated PDF?
user147031
  • 183
  • 1
  • 2
  • 6
16
votes
2 answers

iTextSharp: SplitLate/SplitRows?

I have an issue where I have a table (PdfPTable) that may extend past the length of the page. I have tried looking up how to "split" a table onto more than one page but iTextSharp is pretty poorly documented in this area. Does anyone know how to do…
Jason
  • 51,583
  • 38
  • 133
  • 185
10
votes
2 answers

How to give margin left to table in itextsharp

I am using these code ...my tables are sticked to left side of document as i havent given any paddings in document... Document document = new Document(PageSize.A4, 0, 0, 0, 0); But now i want to give margin left and margin right to my tables ...i…
ankit sharma
  • 449
  • 1
  • 6
  • 17
9
votes
2 answers

How to make the table non breaking using iTextSharp

I am having a table PdfPTable tblSummary = new PdfPTable(1); And it does have 2 tables nested within it. How can I make the tblSummary to appear as a whole (the rows must not break to another page) or entire table be shifted to another page…
Vinay
  • 471
  • 3
  • 8
  • 19
9
votes
3 answers

How to Set Height of PdfPTable in iTextSharp

i downloaded the last version of iTextSharp dll. I generated a PdfPTable object and i have to set it's height. Despite to set width of PdfPTable, im not able to set height of it. Some authors suggest to use 'setFixedHeight' method. But the last…
mustafaalkan64
  • 207
  • 1
  • 3
  • 13
7
votes
1 answer

table row is getting started from the new page in itext pdf

I am using PdfPTable to create a table in pdf.I have a single row in the table.In my row last column has data which has height more than remaining height of the page.So row is getting started from the next page while table headers are on the…
Manish
  • 1,274
  • 3
  • 22
  • 59
7
votes
2 answers

iTextSharp - Use Colspan with PdfPRow

I am able to create multiple rows if they contain the same number of columns: table = new PdfPTable(3); var firstRowCell1 = new PdfPCell( new Phrase ("Row 1 - Column 1")); var firstRowCell2 = new PdfPCell( new Phrase ("Row 2 - Column 2")); var…
Baxter
  • 5,633
  • 24
  • 69
  • 105
6
votes
2 answers

How to fill a PdfPTable column by column instead of row by row, using iText

I am using Java with iText in order to generate some PDFs. I need to put text in columns, so I am trying to use PdfPTable. I create it with: myTable = new PdfPTable(n); n being the number of columns. The problem is that PdfPTable fills the table…
user2061099
5
votes
1 answer

Jumping to the next page in iTextSharp PdfPtable when creating one for a PdfPDocument document

I'm building up an iTextSharp PdfPTable object that will later be passed to Document.Add() to be populated to a PDF file. I'm going crazy over trying to figure out how to jump to the next page. Can anyone advise how to format the table and make the…
InspiredBy
  • 4,271
  • 6
  • 40
  • 67
5
votes
1 answer

How to change the width of a cell?

I need your help in setting the length of a cell's bottom border. Currently, it is showing the bottom border of a cell too long and I need to shorten it. I tried to change the width of the table, but it is not coming properly. Below is the…
99maas
  • 1,239
  • 12
  • 34
  • 59
4
votes
0 answers

Need to give page break in inner PdfPTable of iTextSharp

I am printing my html string in to pdf using iTextSharp. I have nested table hierarchy. I need the Inner table should be break if its not fit in the current page and Start printing on new page. I have putted the KeepTogether = true; SplitLate =…
Herin
  • 704
  • 3
  • 18
  • 34
4
votes
1 answer

Cell background color affects the color of other lines

I'm creating a PDF where I add some text to each page as well as 2 lines that are drawn using the following method: private void DrawLines(Document pdfDoc, PdfContentByte cb) { cb.MoveTo(0, 562); cb.LineTo(pdfDoc.PageSize.Width, 562); …
Annadate Piyush
  • 458
  • 5
  • 18
4
votes
1 answer

how do I add bookmark into a pdfpcell

I am doing a report which contains more 1000 records by using pdfptable of itext. it is not easy to seek a particular record, so i am wondering if there is any way to add bookmark in a pdfpcell.
roy
  • 41
  • 2
4
votes
1 answer

How to define a default font to create a PDF with a PdfPTable and the PdfAWriter class from iText 5.3.3 library

I'm working with the library iText 5.3.3 and i wan't to create a PDF with the class PdfAWriter which needs to specify which compliancelevel must be respected. I wan't to add a PdfPTable to my document but i don't manage to do it cause of this error…
alain carette
  • 41
  • 1
  • 1
  • 3
1
2 3 4 5 6 7 8