Alex Gordon
Alex Gordon

Reputation: 60761

itextsharp: detecting if text / images are not fitting on page

i am generating a report in vb.net using itextsharp. sometimes the entire report does not fit on one page and i need to know when itextsharp is adding a page to the document. is there a way to detect this?

Upvotes: 0

Views: 1499

Answers (1)

jball
jball

Reputation: 25014

As long as you're implementing the PdfPageEvent interface, you just need to override the public void onEndPage(PdfWriter writer, Document document) method, which is called right before a new page is started.

Edit: here's some code explaining the procedure, without knowing what you want to do if a new page is created by iTextSharp, this is the most I can give you:

Public Class YourReport
  Implements PdfPageEvent

  'Your report code

  Public Overrides Sub onEndPage(ByVal writer as PdfWriter, 
                                       ByVal doc as Document)
    'if you get here, a new page was created by iTextSharp 
    'so do what you need to do.
  End Sub

End Class

Upvotes: 3

Related Questions