Maybe somebody has some idea how to deal with the following situation...
Inside my solution I do use the PDF component to create some pdfs on the fly insiode my code. There are some text and grid elements over more than one page.
The problem I have now is the footer I should create (on every page of the doc with mutliple information inside). I create the footer at the end of the doc generation for every page like that
- Code: Select all
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
foreach (PdfPageBase p in this.doc.Sections[0])
{
PdfStringFormat formatRight = new PdfStringFormat(PdfTextAlignment.Right) { MeasureTrailingSpaces = true };
PdfStringFormat formatCenter = new PdfStringFormat(PdfTextAlignment.Center) { MeasureTrailingSpaces = true };
PdfStringFormat formatLeft = new PdfStringFormat(PdfTextAlignment.Left) { MeasureTrailingSpaces = true };
float x = unitCvtr.ConvertUnits(this.margin.Left, PdfGraphicsUnit.Point, PdfGraphicsUnit.Centimeter);
float width = p.Canvas.ClientSize.Width
- unitCvtr.ConvertUnits(
this.margin.Left,
PdfGraphicsUnit.Point,
PdfGraphicsUnit.Centimeter)
- unitCvtr.ConvertUnits(
this.margin.Right,
PdfGraphicsUnit.Point,
PdfGraphicsUnit.Centimeter);
float y = p.Canvas.ClientSize.Height
- unitCvtr.ConvertUnits(this.margin.Bottom, PdfGraphicsUnit.Point, PdfGraphicsUnit.Centimeter);
p.Canvas.DrawLine(this.blackPen, x, y - 9, x + width, y - 9);
y = y + 1;
string numberLabel = string.Format("Seite {0} von {1}", startNumber++, pageCount);
p.Canvas.DrawString(
string.Format("Name: {0} {1}", b.Name, b.Vorname),
this.fontArial8,
this.brSchwarz,
0,
y - 9,
formatLeft);
p.Canvas.DrawString(
string.Format("Personal-Nr: {0}", b.IdMitarbeiter),
this.fontArial8,
this.brSchwarz,
width/2,
y - 9,
formatCenter);
p.Canvas.DrawString(numberLabel, this.fontArial8, this.brSchwarz, x + width, y - 9, formatRight);
}
my main problem now is that some grids with any kind of content are big enough to reach the end of the page an go over my footer element. Tried to use the PaginateBounds of the PdfGridLayoutFormat like that
- Code: Select all
SizeF sizeBounds = this.doc.Sections[0].Pages[0].GetClientSize().ToSize();
this.tableLayout = new PdfGridLayoutFormat
{
Layout = PdfLayoutType.Paginate,
PaginateBounds =
new RectangleF(
0,
0,
sizeBounds.Width,
sizeBounds.Height - 20)
};
but they seem to be ignored ....or I do something wrong.
Does anybody have an Idea how to do that so that the PaginateBounds work as expected?
Thnx in advance
Matthias