Skip to content

Commit be14647

Browse files
committed
1002794: Updated UG documentation with File overload support for Cross platform
1 parent a432bf4 commit be14647

File tree

4 files changed

+37
-56
lines changed
  • Merge PDFs
    • Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs
    • Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags
    • Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream
    • Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents

4 files changed

+37
-56
lines changed

Merge PDFs/Extend-the-margin-of-PDF-pages-while-merging-PDFs/.NET/Extend-the-margin-of-PDF-pages-while-merging-PDFs/Program.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@
1010
documentMargins.All = 50;
1111
//Set the document margins
1212
outputDocument.PageSettings.Margins = documentMargins;
13-
//Load the first PDF document
14-
using (FileStream firstPDFStream = new FileStream(Path.GetFullPath(@"Data/File1.pdf"), FileMode.Open, FileAccess.Read))
15-
{
16-
//Load the second PDF document
17-
using (FileStream secondPDFStream = new FileStream(Path.GetFullPath(@"Data/File2.pdf"), FileMode.Open, FileAccess.Read))
18-
{
19-
//Create a list of streams to merge
20-
Stream[] streams = { firstPDFStream, secondPDFStream };
21-
//Create a merge options object
22-
PdfMergeOptions mergeOptions = new PdfMergeOptions();
23-
//Enable the extend margin option
24-
mergeOptions.ExtendMargin = true;
25-
//Merge the PDF documents
26-
PdfDocumentBase.Merge(outputDocument, mergeOptions, streams);
27-
//Save the document
28-
outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
29-
}
13+
//Creates a string array of source files to be merged.
14+
string[] source = { Path.GetFullPath(@"Data/File1.pdf"), Path.GetFullPath(@"Data/File2.pdf") };
15+
//Create a merge options object
16+
PdfMergeOptions mergeOptions = new PdfMergeOptions();
17+
//Enable the extend margin option
18+
mergeOptions.ExtendMargin = true;
19+
//Merge the PDF documents
20+
PdfDocumentBase.Merge(outputDocument, mergeOptions, source);
21+
//Save the document
22+
outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
23+
outputDocument.Close(true);
3024
}

Merge PDFs/Merge-PDF-without-compromising-accessibility-tags/.NET/Merge-PDF-without-compromising-accessibility-tags/Program.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@
22

33
//Create a PDF document.
44
PdfDocument finalDoc = new PdfDocument();
5-
//Get stream from the PDF documents.
6-
using (FileStream stream1 = new FileStream(Path.GetFullPath(@"Data/File1.pdf"), FileMode.Open, FileAccess.Read))
7-
using (FileStream stream2 = new FileStream(Path.GetFullPath(@"Data/File2.pdf"), FileMode.Open, FileAccess.Read))
8-
{
9-
//Create a PDF stream for merging.
10-
Stream[] streams = { stream1, stream2 };
11-
PdfMergeOptions mergeOptions = new PdfMergeOptions();
5+
//Creates a string array of source files to be merged.
6+
string[] source = { Path.GetFullPath(@"Data/File1.pdf"), Path.GetFullPath(@"Data/File2.pdf") };
7+
PdfMergeOptions mergeOptions = new PdfMergeOptions();
128

13-
//Enable the Merge Accessibility Tags.
14-
mergeOptions.MergeAccessibilityTags = true;
9+
//Enable the Merge Accessibility Tags.
10+
mergeOptions.MergeAccessibilityTags = true;
1511

16-
//Merge PDFDocument.
17-
PdfDocumentBase.Merge(finalDoc, mergeOptions, streams);
12+
//Merge PDFDocument.
13+
PdfDocumentBase.Merge(finalDoc, mergeOptions, source);
1814

19-
//Save the PDF document
20-
finalDoc.Save(Path.GetFullPath(@"Output/Output.pdf"));
15+
//Save the PDF document
16+
finalDoc.Save(Path.GetFullPath(@"Output/Output.pdf"));
2117

22-
//Close the documents.
23-
finalDoc.Close(true);
24-
}
18+
//Close the documents.
19+
finalDoc.Close(true);

Merge PDFs/Merge-multiple-documents-from-stream/.NET/Merge-multiple-documents-from-stream/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
//Creates a PDF document.
44
using (PdfDocument document = new PdfDocument())
55
{
6-
using FileStream stream1 = new FileStream(Path.GetFullPath(@"Data/file1.pdf"), FileMode.Open, FileAccess.Read);
7-
using FileStream stream2 = new FileStream(Path.GetFullPath(@"Data/file2.pdf"), FileMode.Open, FileAccess.Read);
8-
//Creates a PDF stream for merging.
9-
Stream[] streams = { stream1, stream2 };
6+
//Creates a string array of source files to be merged.
7+
string[] source = { Path.GetFullPath(@"Data/file1.pdf"), Path.GetFullPath(@"Data/file2.pdf") };
108
//Merges PDFDocument.
11-
PdfDocumentBase.Merge(document, streams);
9+
PdfDocumentBase.Merge(document, source);
1210
//Save the merged document
1311
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
12+
document.Close(true);
1413
}

Merge PDFs/Optimize-the-PDF-resources-when-merging-PDF-documents/.NET/Optimize-the-PDF-resources-when-merging-PDF-documents/Program.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@
33
//Create a new PDF document
44
using (PdfDocument outputDocument = new PdfDocument())
55
{
6-
//Load the first PDF document
7-
using (FileStream firstPDFStream = new FileStream(Path.GetFullPath(@"Data/File1.pdf"), FileMode.Open, FileAccess.Read))
8-
{
9-
//Load the second PDF document
10-
using (FileStream secondPDFStream = new FileStream(Path.GetFullPath(@"Data/File2.pdf"), FileMode.Open, FileAccess.Read))
11-
{
12-
//Create a list of streams to merge
13-
Stream[] streams = { firstPDFStream, secondPDFStream };
14-
//Create a merge options object
15-
PdfMergeOptions mergeOptions = new PdfMergeOptions();
16-
//Enable the optimize resources option
17-
mergeOptions.OptimizeResources = true;
18-
//Merge the PDF documents
19-
PdfDocumentBase.Merge(outputDocument, mergeOptions, streams);
20-
//Save the document
21-
outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
22-
}
23-
}
6+
//Creates a string array of source files to be merged.
7+
string[] source = { Path.GetFullPath(@"Data/File1.pdf"), Path.GetFullPath(@"Data/File2.pdf") };
8+
//Create a merge options object
9+
PdfMergeOptions mergeOptions = new PdfMergeOptions();
10+
//Enable the optimize resources option
11+
mergeOptions.OptimizeResources = true;
12+
//Merge the PDF documents
13+
PdfDocumentBase.Merge(outputDocument, mergeOptions, source);
14+
//Save the document
15+
outputDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
16+
outputDocument.Close();
2417
}

0 commit comments

Comments
 (0)