You can find more details at: Merge XPS Files Programmatically in C#
Last active
June 28, 2022 09:19
-
-
Save aspose-com-gists/7f6563854a9626c9de9c7ad84431df43 to your computer and use it in GitHub Desktop.
Merge or Combine XPS Files Programmatically in C# .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PDF output stream | |
using (Stream pdfStream = File.Open("mergedXPSfiles.pdf", FileMode.Create, FileAccess.Write)) | |
// Initialize XPS input stream | |
using (Stream xpsStream = File.Open("input.xps", FileMode.Open, FileAccess.Read)) | |
{ | |
// Load the first XPS document from the stream | |
XpsDocument document = new XpsDocument(xpsStream, new XpsLoadOptions()); | |
// Initialize options object with necessary parameters. | |
PdfSaveOptions options = new PdfSaveOptions() | |
{ | |
JpegQualityLevel = 100, | |
ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg, | |
TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate | |
}; | |
// Create rendering device for PDF format | |
PdfDevice device = new PdfDevice(pdfStream); | |
// Create an array of XPS files that will be merged with the first one | |
string[] filesToMerge = new string[] { "input2.xps", "input3.xps" }; | |
// Merge XPS files to output PDF document | |
document.Merge(filesToMerge, device, options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize XPS output stream | |
using (System.IO.Stream outStream = System.IO.File.Open("mergedXPSfiles.xps", System.IO.FileMode.Create, System.IO.FileAccess.Write)) | |
{ | |
// Load XPS document | |
XpsDocument document = new XpsDocument("input.xps", new XpsLoadOptions()); | |
// Create an array of XPS files that will be merged with the first one | |
string[] filesToMerge = new string[] { "input2.xps", "input3.xps" }; | |
// Merge XPS files to output XPS document | |
document.Merge(filesToMerge, outStream); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PDF output stream | |
using (Stream pdfStream = File.Open("mergedXPSfiles.pdf", FileMode.Create, FileAccess.Write)) | |
// Initialize XPS input stream | |
using (Stream xpsStream = File.Open("input.xps", FileMode.Open, FileAccess.Read)) | |
{ | |
// Load the first XPS document from the stream | |
XpsDocument document = new XpsDocument(xpsStream, new XpsLoadOptions()); | |
// Create rendering device for PDF format | |
PdfDevice device = new PdfDevice(pdfStream); | |
// Create an array of XPS files that will be merged with the first one | |
string[] filesToMerge = new string[] { "input2.xps", "input3.xps" }; | |
// Merge XPS files to output PDF document | |
document.Merge(filesToMerge, device, new PdfSaveOptions()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment