I have a PdfPTable
which I have specified the SplitLate property to false on. I have a scenario
where I have 2 rows. The first row spans the entire page, thus the second row
will display on the second page. If SplitLate is set to true, this works fine.
If SplitLate is set to false, I lose some or all of the content of the second
row. One property that affects this problem is the cell padding. If I set the
padding to 0, all the content will display fine. If I set the padding to say 10,
some or all of the content will not get displayed.
I need to have a
table that has rows that can split right on the page break and that will work
with SplitLate set to false and that can specify padding w/out losing cell
content. Any ideas?
BTW, I am using
iTextSharp -- a June CVS version.
Thanks,
Mitch
Freed
Example:
iTextSharp.text.Document document = new
iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER, 21.6f, 21.6f, 21.6f,
21.6f);
System.IO.MemoryStream ms = new MemoryStream();
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, ms);
System.IO.MemoryStream ms = new MemoryStream();
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, ms);
document.Open();
iTextSharp.text.pdf.PdfContentByte cb =
writer.DirectContent;
iTextSharp.text.pdf.ColumnText ct1 = new iTextSharp.text.pdf.ColumnText(cb);
iTextSharp.text.pdf.ColumnText ct1 = new iTextSharp.text.pdf.ColumnText(cb);
Paragraph p1
= new
Paragraph("a\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\n");
Paragraph p2 = new Paragraph("blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. ");
PdfPTable p = new PdfPTable(1);
p.SplitLate = false;
Paragraph p2 = new Paragraph("blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. blah blah blah. ");
PdfPTable p = new PdfPTable(1);
p.SplitLate = false;
PdfPCell c1
= new PdfPCell();
c1.UseDescender = true;
c1.UseAscender = true;
c1.UseBorderPadding = true;
c1.PaddingLeft = 3f;
c1.PaddingRight = 3f;
c1.PaddingTop = 3f;
c1.PaddingBottom = 3f;
c1.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER | iTextSharp.text.Rectangle.RIGHT_BORDER;
c1.BorderWidth = 3f;
c1.AddElement(p1);
c1.UseDescender = true;
c1.UseAscender = true;
c1.UseBorderPadding = true;
c1.PaddingLeft = 3f;
c1.PaddingRight = 3f;
c1.PaddingTop = 3f;
c1.PaddingBottom = 3f;
c1.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER | iTextSharp.text.Rectangle.RIGHT_BORDER;
c1.BorderWidth = 3f;
c1.AddElement(p1);
PdfPCell c2
= new PdfPCell();
c2.UseDescender = true;
c2.UseAscender = true;
c2.UseBorderPadding = true;
c2.PaddingLeft = 3f;
c2.PaddingRight = 3f;
c2.PaddingTop = 0f;
c2.PaddingBottom = 0f;
c2.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER | iTextSharp.text.Rectangle.RIGHT_BORDER;
c2.BorderWidth = 3f;
c2.AddElement(p2);
c2.UseDescender = true;
c2.UseAscender = true;
c2.UseBorderPadding = true;
c2.PaddingLeft = 3f;
c2.PaddingRight = 3f;
c2.PaddingTop = 0f;
c2.PaddingBottom = 0f;
c2.Border = iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.BOTTOM_BORDER | iTextSharp.text.Rectangle.LEFT_BORDER | iTextSharp.text.Rectangle.RIGHT_BORDER;
c2.BorderWidth = 3f;
c2.AddElement(p2);
p.AddCell(c1);
p.AddCell(c2);
p.SetWidths(new float[] {100});
p.AddCell(c2);
p.SetWidths(new float[] {100});
ct1.AddElement(p);
int status =
0;
while ((status & iTextSharp.text.pdf.ColumnText.NO_MORE_TEXT) == 0)
{
ct1.SetSimpleColumn(document.Left, document.Bottom, document.Right, document.Top);
status = ct3.Go();
if ((status & iTextSharp.text.pdf.ColumnText.NO_MORE_TEXT) == 0)
document.NewPage();
}
while ((status & iTextSharp.text.pdf.ColumnText.NO_MORE_TEXT) == 0)
{
ct1.SetSimpleColumn(document.Left, document.Bottom, document.Right, document.Top);
status = ct3.Go();
if ((status & iTextSharp.text.pdf.ColumnText.NO_MORE_TEXT) == 0)
document.NewPage();
}
document.Close();
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
