tags:

views:

17

answers:

1

Hi, I'm wondering if the dimensions of a page can be altered after content has been added to it?

I'm creating a PDF document in code using iTextSharp, and placing some content on a page. I'll only know the height of the content after drawing it, then I need to basically "crop" the page, so that it's only as tall as the content.

I know I can do this by writing the content to a pdfTemplate, then doing SetPageSize() and NewPage(), then adding the template to the new page. However, this document must only have 1 page. That's the catch - I can't set the size of page 1 after the fact, only subsequent pages, but the doc must only contain one page.

Unless there's a way of deleting page 1 after adding the properly-sized second page, I can't think of how to achieve this: A one-page PDF whose page size I have to change after having written content to it.

Many thanks if anyone can help!

A: