ITextSharp Out of memory exception merging multiple pdf

前端 未结 1 1541
借酒劲吻你
借酒劲吻你 2021-01-19 01:39

I have to merge multiple 1 page pdf\'s into one pdf. I\'m using iTextSHarp 5.5.5.0 to accomplish this, but when I get to merge more than 900-1000 pdf I get an out of memory

相关标签:
1条回答
  • 2021-01-19 02:27

    Since this is a large amount of stuff I'd recommend writing directly to a FileStream instead of a MemoryStream. This might be an actual case where an Out of Memory Exception might literally mean "Out of Memory".

    Also, as Bruno pointed out, the "smart" part of PdfSmartCopy unfortunately comes at the cost of memory, too. Switching to PdfCopy should reduce memory pressure although your final PDF might be larger.

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