Word控件Aspose.Words教程:操作 XPS 和 EPS 文档

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)

以上便是本篇文章的所有内容,要是您还有其他关于产品方面的问题,欢迎咨询我们

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值