使用 .NET API 将 EMF 转换为 EPS

概述

本文讲解如何使用 C# 将 EMF 转换为 EPS 文件。内容涵盖以下主题:

C# 将图像转换为 EPS 文件

本文涵盖了如何使用 C# 将 JPG、TIFF、PNG 等其他格式的图像转换为 EPS 文件。

C# EMF 转 EPS

您可以通过免费在线 <a nofollow 检查 Aspose.Page EMF 转 EPS 的质量并查看结果href=“ https://products.aspose.app/page/conversion/emf-to-eps">EMF 到 EPS 转换器,然后使用我们的 EPS 查看器 查看生成的 EPS 文件


Aspose.Page for .NET EMF 转 EPS 转换器支持使用 .NET 平台支持的任何语言(例如 C#、VB 和 J#)将 EMF 图像转换为封装 PostScript (EPS) 文件。

步骤:C# 语言 EMF 转 EPS 转换器 API 代码

只需执行以下两个步骤即可完成 EMF 转 EPS 转换:

  1. 创建 PsSaveOptions 实例。
  2. 使用 PsDocument 的静态方法 SaveImageToEps

SaveImageToEps 方法有四处修改,以便用户以最便捷的方式将 EMF 图像保存为 EPS 文件。

在 C# 中使用字符串将 EMF 图像保存为 EPS 文件

在以下 C# 代码片段中,输入图像和输出 EPS 文件均通过字符串赋值:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2
 3// The path to the documents directory.
 4string dataDir = GetDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8
 9// Save EMF image to EPS file
10PsDocument.SaveImageAsEps(dataDir + "input1.emf", dataDir + "output1.eps", options);

在 C# 中使用流将 EMF 保存为 EPS

以下 C# 代码片段通过流分配输入图像和输出 EPS 文件:

1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6// Save EMF image to EPS file
7PsDocument.SaveImageAsEps(inputStream, outputStream, options);

在 C# 中使用 Bimap 对象和字符串将 EMF 保存为 EPS

在以下 C# 代码片段中,输入图像由 Bitmap 对象赋值,输出 EPS 文件由字符串赋值:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2
 3// The path to the documents directory.
 4string dataDir = GetDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8// Create the bitmap object from image file
 9using(Bitmap emf = new Bitmap(File.OpenRead(dataDir + "input1.emf")))
10{
11	// Save EMF image to EPS file
12	PsDocument.SaveImageAsEps(emf, dataDir + "output1.eps", options);
13}

对于 Linux、MacOS 和其他非 Windows 操作系统,我们建议使用我们的 Aspose.Page.Drawing Nuget 包。它使用 Aspose.Drawing 后端,而不是 System.Drawing 系统库。

因此,请导入 Aspose.Page.Drawing 命名空间,而不是 System.Drawing 命名空间。在上面和下面的代码片段中,将使用 Aspose.Page.Drawing.Bitmap 代替 System.Drawing.Bitmap。我们在 GitHub 上的代码示例包含所有必要的替换。

在 C# 中使用 Bimap 对象和流将 EMF 保存为 EPS

在以下 C# 代码片段中,输入图像由 Bitmap 对象分配,输出 EPS 文件由流分配:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2
 3// The path to the documents directory.
 4string dataDir = GetDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8// Create the bitmap object from image file
 9using(Bitmap emf = new Bitmap(File.OpenRead(dataDir + "input1.emf")))
10{
11	// Create the output stream fo EPS file
12	using(Stream outputStream = File.OpenWrite(dataDir + "output1.eps"))
13	{
14		// Save EMF image to EPS file
15		PsDocument.SaveImageAsEps(emf, outputStream, options);
16	}
17}

请参阅 JavaC++ 中的 EMF 到 EPS 的转换。

使用我们的 EMF 到 EPS 转换器 在线评估 EMF 到 EPS 的转换效果。您可以一次将多个 EMF 图像转换为 EPS 文件,并在几秒钟内下载结果。

您可以从 GitHub 下载示例和数据文件。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.