From be146478b874efcda796fb90a099d49e82bd1d2f Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Tue, 13 Jan 2026 16:15:40 +0530 Subject: [PATCH] 1002794: Updated UG documentation with File overload support for Cross platform --- .../Program.cs | 28 +++++++----------- .../Program.cs | 27 +++++++---------- .../Program.cs | 9 +++--- .../Program.cs | 29 +++++++------------ 4 files changed, 37 insertions(+), 56 deletions(-) diff --git a/Merge PDFs/Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs/Program.cs b/Merge PDFs/Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs/Program.cs index 50a4cecb..3024afe7 100644 --- a/Merge PDFs/Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs/Program.cs +++ b/Merge PDFs/Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs/Program.cs @@ -10,21 +10,15 @@ documentMargins.All = 50; //Set the document margins outputDocument.PageSettings.Margins = documentMargins; - //Load the first PDF document - using (FileStream firstPDFStream = new FileStream(Path.GetFullPath(@"Data/File1.pdf"), FileMode.Open, FileAccess.Read)) - { - //Load the second PDF document - using (FileStream secondPDFStream = new FileStream(Path.GetFullPath(@"Data/File2.pdf"), FileMode.Open, FileAccess.Read)) - { - //Create a list of streams to merge - Stream[] streams = { firstPDFStream, secondPDFStream }; - //Create a merge options object - PdfMergeOptions mergeOptions = new PdfMergeOptions(); - //Enable the extend margin option - mergeOptions.ExtendMargin = true; - //Merge the PDF documents - PdfDocumentBase.Merge(outputDocument, mergeOptions, streams); - //Save the document - outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf")); - } + //Creates a string array of source files to be merged. + string[] source = { Path.GetFullPath(@"Data/File1.pdf"), Path.GetFullPath(@"Data/File2.pdf") }; + //Create a merge options object + PdfMergeOptions mergeOptions = new PdfMergeOptions(); + //Enable the extend margin option + mergeOptions.ExtendMargin = true; + //Merge the PDF documents + PdfDocumentBase.Merge(outputDocument, mergeOptions, source); + //Save the document + outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf")); + outputDocument.Close(true); } diff --git a/Merge PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs b/Merge PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs index af67df45..7128b502 100644 --- a/Merge PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs +++ b/Merge PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs @@ -2,23 +2,18 @@ //Create a PDF document. PdfDocument finalDoc = new PdfDocument(); -//Get stream from the PDF documents. -using (FileStream stream1 = new FileStream(Path.GetFullPath(@"Data/File1.pdf"), FileMode.Open, FileAccess.Read)) -using (FileStream stream2 = new FileStream(Path.GetFullPath(@"Data/File2.pdf"), FileMode.Open, FileAccess.Read)) -{ - //Create a PDF stream for merging. - Stream[] streams = { stream1, stream2 }; - PdfMergeOptions mergeOptions = new PdfMergeOptions(); +//Creates a string array of source files to be merged. +string[] source = { Path.GetFullPath(@"Data/File1.pdf"), Path.GetFullPath(@"Data/File2.pdf") }; +PdfMergeOptions mergeOptions = new PdfMergeOptions(); - //Enable the Merge Accessibility Tags. - mergeOptions.MergeAccessibilityTags = true; +//Enable the Merge Accessibility Tags. +mergeOptions.MergeAccessibilityTags = true; - //Merge PDFDocument. - PdfDocumentBase.Merge(finalDoc, mergeOptions, streams); +//Merge PDFDocument. +PdfDocumentBase.Merge(finalDoc, mergeOptions, source); - //Save the PDF document - finalDoc.Save(Path.GetFullPath(@"Output/Output.pdf")); +//Save the PDF document +finalDoc.Save(Path.GetFullPath(@"Output/Output.pdf")); - //Close the documents. - finalDoc.Close(true); -} \ No newline at end of file +//Close the documents. +finalDoc.Close(true); diff --git a/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs b/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs index 4d5f3a9d..73076c87 100644 --- a/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs +++ b/Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs @@ -3,12 +3,11 @@ //Creates a PDF document. using (PdfDocument document = new PdfDocument()) { - using FileStream stream1 = new FileStream(Path.GetFullPath(@"Data/file1.pdf"), FileMode.Open, FileAccess.Read); - using FileStream stream2 = new FileStream(Path.GetFullPath(@"Data/file2.pdf"), FileMode.Open, FileAccess.Read); - //Creates a PDF stream for merging. - Stream[] streams = { stream1, stream2 }; + //Creates a string array of source files to be merged. + string[] source = { Path.GetFullPath(@"Data/file1.pdf"), Path.GetFullPath(@"Data/file2.pdf") }; //Merges PDFDocument. - PdfDocumentBase.Merge(document, streams); + PdfDocumentBase.Merge(document, source); //Save the merged document document.Save(Path.GetFullPath(@"Output/Output.pdf")); + document.Close(true); } \ No newline at end of file diff --git a/Merge PDFs/Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents/Program.cs b/Merge PDFs/Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents/Program.cs index 239c929c..935edf49 100644 --- a/Merge PDFs/Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents/Program.cs +++ b/Merge PDFs/Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents/Program.cs @@ -3,22 +3,15 @@ //Create a new PDF document using (PdfDocument outputDocument = new PdfDocument()) { - //Load the first PDF document - using (FileStream firstPDFStream = new FileStream(Path.GetFullPath(@"Data/File1.pdf"), FileMode.Open, FileAccess.Read)) - { - //Load the second PDF document - using (FileStream secondPDFStream = new FileStream(Path.GetFullPath(@"Data/File2.pdf"), FileMode.Open, FileAccess.Read)) - { - //Create a list of streams to merge - Stream[] streams = { firstPDFStream, secondPDFStream }; - //Create a merge options object - PdfMergeOptions mergeOptions = new PdfMergeOptions(); - //Enable the optimize resources option - mergeOptions.OptimizeResources = true; - //Merge the PDF documents - PdfDocumentBase.Merge(outputDocument, mergeOptions, streams); - //Save the document - outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf")); - } - } + //Creates a string array of source files to be merged. + string[] source = { Path.GetFullPath(@"Data/File1.pdf"), Path.GetFullPath(@"Data/File2.pdf") }; + //Create a merge options object + PdfMergeOptions mergeOptions = new PdfMergeOptions(); + //Enable the optimize resources option + mergeOptions.OptimizeResources = true; + //Merge the PDF documents + PdfDocumentBase.Merge(outputDocument, mergeOptions, source); + //Save the document + outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf")); + outputDocument.Close(); } \ No newline at end of file