“'System.StackOverflowException” in “OnEndPage” event handler

后端 未结 1 1373
梦如初夏
梦如初夏 2020-12-07 06:21

In the code below, you can see that I overrode OnEndPage event and tried to add a paragraph to the document. However, I get an \"System.StackOverflowException\"

相关标签:
1条回答
  • 2020-12-07 06:45

    It is forbidden to use document.Add() in a page event. The document object passed as a parameter is actually a PdfDocument object. You should use it for read-only purposes only. This is documented in my book iText in Action - Second Edition.

    If you want to add content in the OnEndPage method, you need the writer, for instance writer.DirectContent.

    0 讨论(0)
提交回复
热议问题