Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
//Close the documents.
finalDoc.Close(true);
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Loading