0

How can I use CSS properties such as padding, cell-spacing, background color, etc... in iTextSharp?

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
user2115472
  • 137
  • 2
  • 10

2 Answers2

0

You can Use PdfPTable

PdfPTable headerTbl = new PdfPTable(2);   //Create table with 2 Cols
headerTbl.SetWidths(new float[] { 4, 1 });    //1st having size of 4 and other 1
headerTbl.TotalWidth = doc.PageSize.Width;   //Total Width of the table
headerTbl.SpacingBefore = 20f;
headerTbl.SpacingAfter = 30f;

You can Create Cells inside PdfPTable Using this

PdfPCell cell = new PdfPCell
cell.Colspan = 3;                  //Colspan
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right  Horizontal alignment 

References

  1. http://jwcooney.com/2013/08/23/itextsharp-pdfptable-basic-example/
  2. http://www.mikesdotnetting.com/article/86/itextsharp-introducing-tables
  3. http://www.mikesdotnetting.com/article/89/itextsharp-page-layout-with-columns
Dgan
  • 10,077
  • 1
  • 29
  • 51
0

There are plenty of Java examples available that explain how to use XML Worker and CSS: http://itextpdf.com/sandbox/xmlworker

Some of these examples were written in answer to StackOverflow questions about iTextSharp:

In a way, your question is not eligible for StackOverflow because it is too broad (you don't show what you've tried) and it is a duplicate of other questions.

Please make sure that you consult the official documentation, as well StackOverflow questions that have been answered (and accepted) in the past before creating a new question.

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