使用 .NET API 将 EMF 转换为 EPS
概述
本文讲解如何使用 C# 将 EMF 转换为 EPS 文件。内容涵盖以下主题:
- C# 将 EMF 转换为 EPS 文件
- C# 将 EMF 转换为 EPS 文件
- C# 将图像转换为 EPS 文件
- C# 将 EPS 文件转换为 EMF 文件
- C# 如何通过编程将 EMF 转换为 EPS 文件
- C# 将 EMF 另存为 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 文件
只需执行以下两个步骤即可完成 EMF 转 EPS 转换:
- 创建 PsSaveOptions 实例。
- 使用 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}
使用我们的 EMF 到 EPS 转换器 在线评估 EMF 到 EPS 的转换效果。您可以一次将多个 EMF 图像转换为 EPS 文件,并在几秒钟内下载结果。
您可以从 GitHub 下载示例和数据文件。