.NET を使用して EPS ファイルを PDF に結合
Aspose.Page EPS Merger の品質を確認し、結果を確認するには、無料のオンラインツール EPS Merger をご利用ください。
Aspose.Page for .NET EPS Merger を使用すると、.NET プラットフォームでサポートされている任意の言語(C#、VB、J#)を使用して、Encapsulated PostScript (EPS) ファイルを PDF ドキュメントに結合できます。
EPS 結合を実行するには、いくつかの手順を実行する必要があります。
PsDocumentインスタンスを作成します。コンストラクタに最初の EPS ファイルのパスを渡します。このコンストラクタは、マージする EPS コンテンツを読み込みます。- マージする追加の EPS ファイルのファイルパスを含む文字列配列を定義します。例:
string[] epsFiles = { "second.eps", "third.eps" };。 PdfSaveOptionsをインスタンス化し、AdditionalFontsFolderをカスタムフォントが保存されているフォルダーに設定します。また、必要に応じてSuppressError = trueを設定して、重大でないエラーを収集します。document.AddPage(epsFiles);を呼び出し(または適切なマージメソッドを使用)、次にdocument.Save("merged.pdf", pdfSaveOptions);を実行して単一の PDF を生成します。SuppressErrorが true の場合、すべての警告はdocument.Exceptionsに保存されます。保存後にこのコレクションを反復処理して問題を確認できます。
次のコード スニペットは、C# で EPS ファイルを PDF ドキュメントに結合する方法を示しています。
1// Merge several EPS files to one PDF document.
2
3// Initialize PS document with the first EPS file
4PsDocument document = new PsDocument(DataDir + "input.eps");
5
6// Create an array of PostScript files that will be merged with the first one
7string[] filesForMerge = new string[] { DataDir + "input2.eps", DataDir + "input3.eps" };
8
9// If you want to convert Postscript file despite of minor errors set this flag
10bool suppressErrors = true;
11
12//Initialize options object with necessary parameters.
13PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
14// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
15options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
16
17// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
18// But if you need to specify the page size following line
19//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Aspose.Page.Drawing.Size(595, 842));
20
21document.MergeToPdf(OutputDir + "outputPDF_out.pdf", filesForMerge, options);
22
23//Review errors
24if (suppressErrors)
25{
26 foreach (Exception ex in options.Exceptions)
27 {
28 Console.WriteLine(ex.Message);
29 }
30}PdfSaveOptions について考えてみましょう。このクラスを使用すると、EPS を PDF にマージする際にさまざまな変換パラメータを指定できます。
- Size は、結果ドキュメントのページサイズを指定します。
- AdditionalFontsFolder は、フォントの検索場所を指定します。システムフォントフォルダーはデフォルトで常に含まれます。
- SuppressError は、重大ではないエラーが発生した場合の EPS マージの動作を制御します。値が true の場合、マージ後に Exceptions フィールドでそのようなエラーの一覧を表示できます。デフォルト値は true です。
- Debug を指定すると、デバッグ情報をコンソールに出力できます。デフォルト値は false です。
EPS Merger で EPS マージ機能をオンラインで評価できます。
サンプルファイルとデータファイルは GitHub からダウンロードできます。