Hello,
If I set the FooterRows and HeaderRows of a table and then after
rendering of that table, when I add a new table to the pdfDoc, it will
start at FooterRow (it will hide the auto generated footer row of the
previous table). It seems FooterRow height is not considered at all. (sample-1
below)
And also mentioned height is not considered when SkipFirstHeader is
true. Table can not calculate the correct height value on the different
pages and sometimes (mostly on first page), that auto generated footer
exceeds the pages margins. (sample-2 below)
Is it a bug or I am doing something wrong or I should set some other properties?
Thanks for your time.
Sample-1
using System.Diagnostics;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace HeadersAndFooters
{
class Program
{
static void Main(string[] args)
{
using (var pdfDoc = new Document(PageSize.A4))
{
var pdfWriter = PdfWriter.GetInstance(pdfDoc, new
FileStream("Test.pdf", FileMode.Create));
pdfDoc.Open();
var table1 = new PdfPTable(3);
table1.SkipFirstHeader = true;
table1.HeaderRows = 2;
table1.FooterRows = 1;
//header row
table1.AddCell(new Phrase("header-cell-1"));
table1.AddCell(new Phrase("header-cell-2"));
table1.AddCell(new Phrase("header-cell-3"));
//footer row
table1.AddCell(new Phrase("footer-cell-1"));
table1.AddCell(new Phrase("footer-cell-2"));
table1.AddCell(new Phrase("footer-cell-3"));
//adding some rows
for (int i = 0; i < 7; i++)
{
table1.AddCell(new Phrase("cell" + i + 1));
table1.AddCell(new Phrase("cell" + i + 2));
table1.AddCell(new Phrase("cell" + i + 3));
}
pdfDoc.Add(table1);
//now adding another table to the pdfDoc
var table2 = new PdfPTable(3);
table2.AddCell(new Phrase("Table2-cell-1"));
table2.AddCell(new Phrase("Table2-cell-2"));
table2.AddCell(new Phrase("Table2-cell-3"));
//this table overlaps the auto generated footer of the table1,
//if I remove "table1.SkipFirstHeader = true" it works fine
//and won't hide the last row
pdfDoc.Add(table2);
}
//open the final file with adobe reader for instance.
Process.Start("Test.pdf");
}
}
}
Sample -2
using System;
using System.Diagnostics;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace HeadersAndFooters
{
class Program
{
static void Main(string[] args)
{
using (var pdfDoc = new Document(PageSize.A4))
{
var pdfWriter = PdfWriter.GetInstance(pdfDoc, new
FileStream("Test.pdf", FileMode.Create));
pdfDoc.Open();
var table1 = new PdfPTable(1);
table1.HeaderRows = 4;
table1.FooterRows = 2;
table1.SkipFirstHeader = true;
//header rows
table1.AddCell(new Phrase("header row1"));
table1.AddCell(new Phrase("header row2"));
//footer rows
table1.AddCell(new Phrase("footer row1"));
table1.AddCell(new Phrase("footer row2"));
//adding some rows
for (int i = 0; i < 70; i++) //test it with 7 & 70
{
table1.AddCell(new Phrase("Row " + i));
}
pdfDoc.Add(table1);
pdfDoc.Add(new Phrase("overlap plus calculating the height of
the table in page 1 incorrectly. it goes beyond the margins of PageSize.A4."));
}
//open the final file with adobe reader for instance.
Process.Start("Test.pdf");
}
}
}
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php