0

I'm trying to write an algorithm that will add additional pages to a PDF based on whether a text field gets filled up, and then print the overflow to the added pages.

I'm using iTextSharp with no option to change libraries.

Does anybody have any suggestions on how to flag if the field is overflowing based on the text I put into it?

Edit: Overflow is now being put onto a fresh page. Unfortunately, the original field doesn't take up a full page - it covers about half a page, around the bottom. Overflow is being printed in the same area on the added pages, leaving a massive empty gap at the top of each page.

Does anyone have any ideas on how to resize the field on additional pages?

Mark
  • 155
  • 3
  • 16
  • If you browse my book [The Best iText Questions on StackOverflow](https://leanpub.com/itext_so), you'll notice that your question is a possible duplicate of [How to continue field output on a second page?](http://stackoverflow.com/questions/26853894/how-to-continue-field-output-on-a-second-page) – Bruno Lowagie Jan 29 '15 at 13:33
  • Ok. How do I find out what page an acrofield is on? – Mark Jan 29 '15 at 15:37
  • If you experiment with the example, you'll find `form.getFieldPositions("body").get(0).page`. This returns the page where the first widget annotation of the field with name "body" can be found. – Bruno Lowagie Jan 29 '15 at 15:55
  • And how about if the area on the added page that I want to paste into is bigger than the original field? – Mark Jan 29 '15 at 16:29
  • 1
    ... Isn't that explained in the answer? A new page is added as long as there is more content. So if it doesn't fit the added page, an extra page will be added, and so on, until all the content was added. Also: please don't use the comment sections for questions. It is not forbidden to edit your own question if you realize that your initial question wasn't phrased in a way that was clear enough for people to understand. When on StackOverflow, please follow the rules of StackOverflow. – Bruno Lowagie Jan 29 '15 at 16:47
  • I have updated it with a slightly more in depth explanation – Mark Jan 30 '15 at 10:23
  • Pass a rectangle `rect` to the `triggerNewPage()` method that is smaller than the `pagesize` in the sense that you deduct some space for the margins and you have your answer. I don't know how anybody can help you more... – Bruno Lowagie Jan 30 '15 at 11:12

0 Answers0