Aspose.Words 是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。
Aspose API 支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。
将 XPS 转换为 PDF
Aspose.Page 允许文档转换。例如,您可以将 XPS 转换为 PDF。让我们试试转换的例子。
重要须知
// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithDocumentConversion(); // Initialize PDF output stream using (System.IO.Stream pdfStream = System.IO.File.Open(dataDir + "input.xps", System.IO.FileMode.Create, System.IO.FileAccess.Write)) // Initialize XPS input stream using (System.IO.Stream xpsStream = System.IO.File.Open(dataDir + "XPStoPDF.pdf", System.IO.FileMode.Open, System.IO.FileAccess.Read)) { // Load XPS document form the stream XpsDocument document = new XpsDocument(xpsStream, new XpsLoadOptions()); // or load XPS document directly from file. No xpsStream is needed then. // XpsDocument document = new XpsDocument(inputFileName, new XpsLoadOptions()); // Initialize options object with necessary parameters. 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, PageNumbers = new int[] { 1, 2, 6 } }; // Create rendering device for PDF format Aspose.Page.XPS.Presentation.Pdf.PdfDevice device = new Aspose.Page.XPS.Presentation.Pdf.PdfDevice(pdfStream); document.Save(device, options);
// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java // The path to the documents directory. String dataDir = Utils.getDataDir(); // Initialize PDF output stream FileOutputStream pdfStream = new FileOutputStream(dataDir + "XPStoPDF.pdf"); // Load XPS document XpsDocument document = new XpsDocument(dataDir + "input.xps"); // Initialize options object with necessary parameters. com.aspose.xps.rendering.PdfSaveOptions options = new com.aspose.xps.rendering.PdfSaveOptions(); options.setJpegQualityLevel(100); options.setImageCompression(com.aspose.xps.rendering.PdfImageCompression.Jpeg); options.setTextCompression(com.aspose.xps.rendering.PdfTextCompression.Flate); options.setPageNumbers(new int[] { 1, 2, 6 }); // Create rendering device for PDF format com.aspose.xps.rendering.PdfDevice device = new com.aspose.xps.rendering.PdfDevice(pdfStream); document.save(device, options)
以上便是本篇文章的所有内容,要是您还有其他关于产品方面的问题,欢迎咨询我们