首先,我们将了解 XPS 到 TIFF 转换器 API,以将 XPS 文件转换为 TIFF 格式。接下来,我们将介绍如何进行转换的步骤。最后,我们将提供对免费在线转换工具和其他有用链接的访问,以进一步增强功能。让我们开始吧!
Aspose.Page 最新下载
(一)C# XPS 到 TIFF 转换器 API – 免费下载
为了将XPS 转换为 TIFF,我们将使用Aspose.Page for .NET API。它使我们能够在 C# 应用程序中加载、合并、转换和呈现 XPS、PS和EPS文档。
API的XpsDocument类封装了 XPS 文档。API的TiffSaveOptions类包含管理 TIFF 保存过程所需的选项。ImageDevice类封装了文档对图像的渲染。Save(Device, SaveOptions)方法使用 Device 实例保存 XPS 文档。
请下载 API 的 DLL或使用NuGet安装它。
PM> Install-Package Aspose.Page
(二)如何将 XPS 转换为 TIFF
我们可以按照以下步骤轻松地将 XPS 文件转换为 TIFF 格式:
- 加载XPS 文件。
- 指定TIFF 保存选项。
- 将 XPS另存为 TIFF。
以下部分介绍如何将这些步骤转换为 C# 代码并将 XPS 文件转换为 TIFF 格式。
( 三)使用 C# 将 XPS 转换为 TIFF 图像
我们可以按照以下步骤将 XPS 文件转换为 TIFF 图像:
- 首先,使用XpsDocument类加载 XPS 文档。
- 接下来,使用必要的参数初始化TiffSaveOptions类对象。
- 然后,创建ImageDevice类的一个实例。
- 之后,调用Save()方法将图像保存在ImageDevice对象中。
- 最后,使用ImageDevice将图像保存为 TIFF 文件。
以下代码示例显示如何使用 C# 将 XPS 文件转换为 TIFF 图像。
// This code example demonstrates how to convert XPS to TIFF.// The path to the documents directory.string dataDir = "C:\Files\";// Input filestring inputFileName = dataDir + "sample.xps";// Outut filestring outputFileName = "sample_out.tif";// Initialize XPS input streamusing (Stream xpsStream = File.Open(inputFileName, FileMode.Open, FileAccess.Read)){// Load XPS document form the streamXpsDocument 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.TiffSaveOptions options = new TiffSaveOptions(){SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,Resolution = 300,PageNumbers = new int[] { 1, 2, 6 }};// Create rendering device for PDF formatImageDevice device = new ImageDevice();document.Save(device, options);// Iterate through document partitions (fixed documents, in XPS terms)for (int i = 0; i < device.Result.Length; i++){// Iterate through partition pagesfor (int j = 0; j < device.Result[i].Length; j++){// Initialize image output streamusing (Stream imageStream = System.IO.File.Open(dataDir + Path.GetFileNameWithoutExtension(outputFileName) + "_" + (i + 1) + "_" + (j + 1) +Path.GetExtension(outputFileName), System.IO.FileMode.Create, System.IO.FileAccess.Write))// Write imageimageStream.Write(device.Result[i][j], 0, device.Result[i][j].Length);} // End inner for} // End outer for} // End using
( 四)结论
欢迎下载|体验更多Aspose文档管理产品
获取更多信息请咨询在线客服 或 加入Aspose技术交流群()
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!