Returning iTextSharp PDF as memorystream causes StreamNotSupported

后端 未结 2 1642
半阙折子戏
半阙折子戏 2020-11-30 14:36

I\'m creating a PDF file using the PdfStamper in iTextSharp and return the PDF as a memorystream object to the calling function, that is then used to display the PDF in Tele

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 15:16

    The problem arises because the memory stream gets implicitly closed when the PdfStamper is closed. To prevent this add

    pdfStamper.Writer.CloseStream = false;
    

    before

    pdfStamper.Close();
    

    This instructs the stamper not to close the stream.

提交回复
热议问题