In iTextSharp, can we set the vertical position of the pdfwriter?
Posted
by Pandincus
on Stack Overflow
See other posts from Stack Overflow
or by Pandincus
Published on 2010-05-21T13:52:07Z
Indexed on
2010/05/21
14:40 UTC
Read the original article
Hit count: 384
Hello,
I've recently started using iTextSharp to generate PDF reports from data. It works quite nicely.
In one particular report, I need a section to always appear at the bottom of the page. I'm using the PdfContentByte to create a dashed line 200f from the bottom:
cb.MoveTo(0f, 200f);
cb.SetLineDash(8, 4, 0);
cb.LineTo(doc.PageSize.Width, 200f);
cb.Stroke();
Now I'd like to insert content below that line. However, (as expected) the PdfContentByte methods don't change the vertical position of the PdfWriter. New paragraphs, for example, appear earlier in the page.
// appears wherever my last content was, NOT below the dashed line
doc.Add(new Paragraph("test", _myFont));
Is there some way to instruct the pdfwriter that I'd like to advance the vertical position to below the dashed line now, and continue inserting content there? There is a GetVerticalPosition() method -- it'd be nice if there was a corresponding Setter :-).
// Gives me the vertical position, but I can't change it
var pos = writer.GetVerticalPosition(false);
So, is there any way to set the writer's position by hand? Thanks!
© Stack Overflow or respective owner