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
1
vote
1 answer

How to add 2 tables top to bottom to a single table using PDFPTable in Java

Please check the code here. Facing issue to merge 2 PDFPtable top to bottom. PdfPTable table = new PdfPTable(new float[] { 1.0f, 2.0f, 5.0f, 1.0f, 2.0f }); table.setWidthPercentage(100.0f); ArrayList lHeaders = new…
1
vote
0 answers

How to add a Pdfptable little by little to a document when generating a Pdf from a Html

The application I'm working on generates pdf reports from html files using itextsharp library. Apparently, when large tables are generated, itextsharp allocates a lot of memory (~300 MB for a 200KB file). A solution to this problem is adding the…
1
vote
0 answers

Setting Default Font for PdfPCell with ItextPDF

I have some working code that creates my PdfPTable cells but it seems a bit inefficient. pList.add(i,new Paragraph()); Paragraph p=pList.get(i++); p.setFont(headerFont); p.add(new Chunk("Actual")); p.add(Chunk.NEWLINE); p.add(new…
Wt Riker
  • 514
  • 12
  • 24
1
vote
1 answer

PdfPTable creating extra cells of an image

I am creating a memory stream with a pdf in it. The pdf is supposed to have a table of 4 different images that are written on. Instead the pdf has one table filled out completely with the first image, and a second page with the correct 4 images.…
user7957951
1
vote
1 answer

Is there any easy way to create table elements in itextsharp

I get some values from database and set into itextsharp PdfPCell with title. Here is my some piece of code. var a = _db.persons.SingleOrDefault(m => m.id == Person.Id); var table = new PdfPTable(2) {WidthPercentage = 100}; …
user1372430
1
vote
0 answers

Splitting cells into two using iTextSharp

I'm trying to generate a PDF file using iTextSharp, and I've wrote this code so far: string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); Document doc = new…
User987
  • 3,663
  • 15
  • 54
  • 115
1
vote
1 answer

Split tables into few pages

I have data that I insert into a table of kind of PdfPTable. The data contains of data belongs to few sources, and I should split the data to few pages so that each source will start in a new page. --- 1st data source data --- page break --- 2nd…
InbalIta
  • 61
  • 8
1
vote
0 answers

iTextSharp Tables : Rows not displaying

I have a problem using tables with iTexSharp version 5.5.7.0 . I want to build a catalog of products which are groupped by categories and sub categories. I need to display the category name, the sub caregory name and the products in it. When the sub…
wallou
  • 529
  • 1
  • 4
  • 21
1
vote
0 answers

insert list in a column with the pdfptable itext with data from a HashMap

This model next provides the data of the inserted column in the table row. researched several examples in http://itextpdf.com/book/examples.php but neither specifies how it should be done whens the data comes from a dataset and are converted to a…
Paulo Victor
  • 327
  • 1
  • 4
  • 12
1
vote
1 answer

iText, insert new blank line inside PdfPTable column

How do I insert a new blank line inside a PdfPTable column. \n and n number of spaces has not done the trick for me. This is the java code I am working with. chtbc_report1_table.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { …
optimus
  • 47
  • 1
  • 8
1
vote
0 answers

PDF generation using iText: with table on top of page and copy&paste text, text in table gets last

We generate a PDF for incoming messages to our system using the iText Java library. It uses a table to display some meta data and a paragraph for the message body. Now when we copy and paste the text of the pdf (in Acrobat Reader as well as Firefox…
erik
  • 253
  • 2
  • 11
1
vote
1 answer

How to set background image in PdfPCell in iText?

I am currently using iText to generate PDF reports. I want to set a medium size image as a background in PdfPCell instead of using background color. Is this possible?
Murali
  • 155
  • 1
  • 3
  • 10
1
vote
0 answers

How to set table column width of itextSharp pdf table/document

Document document; document.NewPage(); System.Collections.ArrayList columnWidth = new System.Collections.ArrayList(); for (int i = 0; i < this.dataTable.Columns.Count; i++) { if (i < 2) { …
StackTrace
  • 9,190
  • 36
  • 114
  • 202
1
vote
0 answers

Where's the ProportionalWidths equivalent for 5.4.5 ITextSharp?

I am using ITextSharp 4.1.2 and trying to upgrade to 5.4.5.. while having adjustments about old codes I couldn't find out the ProportionalWidths property for the PdfPTable (old Table) class. Would be pdfptable.SetWidths(new float[] { values }…
Hugo S. Mendes
  • 1,076
  • 11
  • 23
1
vote
0 answers

How to get table layout to span pages horizontally and vertically in iTextsharp?

I am using iTextsharp (version 4.1.6 - an LGPL fork) to generate a PDF that contains simply a table. My project is a .net 4 application. The table can have lots of columns and lots of rows and the PDF will not contain anything else (so I want to…
kmp
  • 10,535
  • 11
  • 75
  • 125