Last active
July 8, 2024 18:11
-
-
Save aspose-com-kb/f3b79fe3cb25b077523f09b56faa9be9 to your computer and use it in GitHub Desktop.
Merge XPS Files in C#. For more details: https://kb.aspose.com/page/net/merge-xps-files-in-csharp/
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
using System.IO; | |
using Aspose.Page; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
new License().SetLicense("License.lic"); | |
// Load XPS document | |
Aspose.Page.XPS.XpsDocument document = new Aspose.Page.XPS.XpsDocument("input.xps", new Aspose.Page.XPS.XpsLoadOptions()); | |
// Initialize PdfSaveOptions object | |
Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions options = new Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions() | |
{ | |
JpegQualityLevel = 100, | |
ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg, | |
TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate | |
}; | |
// Create Stream object | |
var fileStream = new FileStream("mergedXPS.pdf", FileMode.Create, FileAccess.Write); | |
// Create a Device for PDF | |
Aspose.Page.Device device = new Aspose.Page.XPS.Presentation.Pdf.PdfDevice(fileStream); | |
// Create an XPS files | |
string[] filesToMerge = new string[] { "input.xps", "input.xps" }; | |
// Merge XPS files | |
document.Merge(filesToMerge, device, options); fileStream.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment