Input data is 32 Pdf document, each of them have 250 page. So my final Pdf document after merge will have 8000 page, and it's size is approximately 1 GB.
- Code: Select all
using (var pdfDoc = new PdfDocument())
{
listTempPDFFileNames.Where(printData => File.Exists(printData.FullPathFile))
.ToList()
.ForEach(x =>
{
var tempPdfDoc = new PdfDocument(x.FullPathFile);
pdfDoc.AppendPage(tempPdfDoc);
});
if (pdfDoc.Pages.Count > 0)
{
pdfDoc.SaveToFile(finalPDF); //This line cause System.OutOfMemoryException
pdfDoc.Close();
}
}