-2

I am new to generating the invoice using ItextSharp in C# . How can I generate he PDF with the following layout attached herewith

Customer Code - Test Customer Name - Test Customr Invoice No - 122 Invoice Date - 12/04/2016

androidpol
  • 65
  • 1
  • 1
  • 9
  • Have you tried to do this with two column table? – lukbl Apr 18 '16 at 20:29
  • Please can you give an example with two column table. It would be very appreciate – androidpol Apr 19 '16 at 05:37
  • 1
    http://stackoverflow.com/questions/29575142/how-to-align-two-paragraphs-to-the-left-and-right-on-the-same-line – lukbl Apr 19 '16 at 06:28
  • @lukbl I'd essentially call the current question a duplicate of that one; that one is for JAva but the concepts are trivial to translate to the .net world. – mkl Apr 19 '16 at 08:06

1 Answers1

2

Please read the official documentation and you'll find the answer to questions such as:

There are also more general chapters, for instance the Q&A about tables. I'm mentioning this part of the site, because it looks as if you're trying to create a PdfPTable:

Try creating a table like this:

public static PdfPTable CreateFirstTable() {
  // a table with three columns
  PdfPTable table = new PdfPTable(3);
  // the cell object
  PdfPCell cell;
  // we add a cell with colspan 3
  cell = new PdfPCell(new Phrase("Cell with colspan 3"));
  cell.Colspan = 3;
  table.AddCell(cell);
  // now we add a cell with rowspan 2
  cell = new PdfPCell(new Phrase("Cell with rowspan 2"));
  cell.Rowspan = 2;
  table.AddCell(cell);
  // we add the four remaining cells with addCell()
  table.AddCell("row 1; cell 1");
  table.AddCell("row 1; cell 2");
  table.AddCell("row 2; cell 1");
  table.AddCell("row 2; cell 2");
  return table;
}

Now add this table to a Document:

document.add(CreateFirstTable());

This simple table should give you an idea on how the principle works. You need a table with two columns to which you can add as many cells with customer codes and invoices as you want.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165