itextsharp:检测文本/图像是否适合页面

时间:2009-12-21 17:14:36

标签: vb.net pdf itextsharp

我使用itextsharp在vb.net中生成报告。有时整个报告不适合一页,我需要知道itextsharp何时向文档添加页面。有没有办法检测到这个?

1 个答案:

答案 0 :(得分:3)

只要您实现PdfPageEvent接口,就需要覆盖public void onEndPage(PdfWriter writer, Document document)方法,该方法在新页面启动之前调用。

编辑:这里有一些代码解释了这个程序,如果iTextSharp创建了一个新的页面,你不知道自己想做什么,这是我能给你的最多的:

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