iTextSharp vertical page fill

Aaron

I'm trying to find something like \vfill from Latex in iTextSharp (a way to insert spaces and place text at the bottom of the page). It's only for one page, not a footer.

I searched online and in the book iText in Action, but didn't find any answers.

Aaron

OK, after a long time and trying many things, I have found a solution.

Some things I tried that "worked", but not good enough:

First I calculated the height of my paragraph (by writing it in a new table in a new document in the RAM), then I would add newlines until there was just enough room for my text. Result: NOT a good way, the text would by off by a few points (the y position in the document, because of the newlines).

Then I tried to do this with ColumnText: too many calculations (since my document is dynamic) and I didn't like positioning it absolute.

So my solution is to use a PdfPTable:

            var t = new PdfPTable(1);
            t.ExtendLastRow = true;
            t.WidthPercentage = 100; 

            var c = new PdfPCell();
            c.VerticalAlignment = Element.ALIGN_BOTTOM;
            c.DisableBorderSide(Rectangle.BOX);

            var p = new Paragraph("This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.");
            p.Alignment = Element.ALIGN_JUSTIFIED;

            c.AddElement(p);

            t.AddCell(c);

            doc.Add(t);

Pretty simple, but I lost a lot of time on this. I hope this helps others too.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to draw vertical gradient in iTextSharp?

From Dev

How to fill in radio button with iTextSharp

From Dev

iTextSharp insert a page at the beginning

From Dev

Header of Page with iTextSharp

From Dev

iTextSharp - PDF Bookmark not pointing to a page

From Dev

iTextSharp: Header on only First Page

From Dev

Masonry vertical fill before horizontal

From Dev

Bootstrap - fill remaining vertical space

From Dev

Java GridBagLayout - disable vertical fill

From Dev

iOS - Fill Available Vertical Space

From Dev

Vertical fill with Angular Material & Flex

From Dev

vertical line on the middle of the page

From Dev

vertical line on the middle of the page

From Dev

Vertical link in page sides

From Dev

iTextSharp PdfWriter Rotating page layout when it shouldnt be

From Dev

Is it possible to convert PDF page to Image using itextSharp?

From Dev

Error in converting aspx page to html (itextsharp 5.0.6)

From Dev

Bookmark to specific page using iTextSharp 4.1.6

From Dev

ITextSharp add page numbers to merged pdf

From Dev

put page number when create PDF with iTextSharp

From Dev

ITextSharp - include footer on every page but the first and the last

From Dev

iTextSharp table pushing another table to a new page

From Dev

iTextSharp Resize each page to fit the pagesize

From Dev

Allow page extraction in a password security pdf with itextsharp

From Dev

ITextSharp open pdf at page index with zoom

From Dev

iTextSharp PdfWriter Rotating page layout when it shouldnt be

From Dev

iTextSharp adding new instances of an existing page

From Dev

Get PDF be written in the center of the page itextsharp

From Dev

iTextsharp - Get rotation of pdf page in C#

Related Related

HotTag

Archive