.NET API を使用して EMF から EPS へ変換

概要

この記事では、C# を使用して EMF を EPS に変換する方法 について説明します。以下のトピックを取り上げます。

C# 画像から EPS へ

これらの記事では、C# を使用して JPG、TIFF、PNG などの他の形式から EPS へ画像に変換する方法について説明します。

C# EMF から EPS への変換

Aspose.Page による EMF から EPS への変換品質を確認し、無料のオンライン コンバータで結果を確認できます。 EMF から EPS へのコンバーター を使用し、生成された EPS ファイルを EPS ビューアー で表示します。


Aspose.Page for .NET の EMF から EPS へのコンバーターを使用すると、.NET プラットフォームでサポートされている任意の言語(C#、VB、J#)を使用して、EMF 画像を Encapsulated PostScript (EPS) ファイルに変換できます。

手順:C# での EMF から EPS へのコンバーター API コード

EMF から EPS への変換は、以下の 2 つの手順で実行できます。

  1. PsSaveOptions のインスタンスを作成します。
  2. PsDocument の静的メソッド SaveImageToEps を使用します。

SaveImageToEps メソッドには、EMF 画像を EPS 形式に保存するための最も簡単な方法を提供するために、4 つの変更が加えられています。

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# で EMF を EPS に保存するために Bimap オブジェクトと文字列を使用する

次の 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以外のOSでは、 Aspose.Page.Drawing NuGetパッケージをご利用いただけます。このパッケージは、System.Drawingシステムライブラリではなく、Aspose.Drawingバックエンドを使用します。

そのため、System.Drawing名前空間ではなく、Aspose.Page.Drawing名前空間をインポートしてください。上記および以下のコードスニペットでは、System.Drawing.Bitmapではなく、Aspose.Page.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への変換については、 JavaC++をご覧ください。

EMF to EPS Converterで、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.