private string mergeMultipleReports() { // It's an in-memory PDF report var file1ContentBytes = new PdfReportToArray().CreatePdfReport(); var file1Path = Path.Combine(AppPath.ApplicationPath, "Pdf\\PdfReportToArray.pdf"); File.WriteAllBytes(file1Path, file1ContentBytes); using (var mergedFileStream = new MemoryStream()) { new MergePdfDocuments { DocumentMetadata = new DocumentMetadata { Author = "Vahid", Application = "PdfRpt", Keywords = "Test", Subject = "MergePdfFiles Rpt.", Title = "Test" }, InputFileStreams = new Stream[] { // Using the input in-memory PDF report(s) new MemoryStream(file1ContentBytes), new MemoryStream(file1ContentBytes) }, OutputFileStream = mergedFileStream, AttachmentsBookmarkLabel = "Attachment(s) ", WriterCustomizer = importedPageInfo => { addNewPageNumbersToFinalMergedFile(importedPageInfo); } }.PerformMerge(); // It's still an in-memory PDF file. Save it to a file or flush it in the browser. var mergedFileContentBytes = mergedFileStream.ToArray(); // Save it to a file. var finalMergedFile = Path.Combine(AppPath.ApplicationPath, "Pdf\\mergedFile.pdf"); File.WriteAllBytes(finalMergedFile, mergedFileContentBytes); return(finalMergedFile); } }
private string mergeMultipleReports() { // It's an in-memory PDF report var file1ContentBytes = new PdfReportToArray().CreatePdfReport(); var file1Path = Path.Combine(AppPath.ApplicationPath, "Pdf\\PdfReportToArray.pdf"); File.WriteAllBytes(file1Path, file1ContentBytes); using (var mergedFileStream = new MemoryStream()) { new MergePdfDocuments { DocumentMetadata = new DocumentMetadata { Author = "Vahid", Application = "PdfRpt", Keywords = "Test", Subject = "MergePdfFiles Rpt.", Title = "Test" }, InputFileStreams = new Stream[] { // Using the input in-memory PDF report(s) new MemoryStream(file1ContentBytes), new MemoryStream(file1ContentBytes) }, OutputFileStream = mergedFileStream, AttachmentsBookmarkLabel = "Attachment(s) ", WriterCustomizer = importedPageInfo => { addNewPageNumbersToFinalMergedFile(importedPageInfo); } }.PerformMerge(); // It's still an in-memory PDF file. Save it to a file or flush it in the browser. var mergedFileContentBytes = mergedFileStream.ToArray(); // Save it to a file. var finalMergedFile = Path.Combine(AppPath.ApplicationPath, "Pdf\\mergedFile.pdf"); File.WriteAllBytes(finalMergedFile, mergedFileContentBytes); return finalMergedFile; } }