.NET を使用して PostScript ファイルを PDF に結合する

Aspose.Page PS Merger の品質を確認し、結果を確認するには、無料のオンラインツール PostScipt Merger をご利用ください。

Aspose.Page for .NET PS Merger を使用すると、.NET プラットフォームでサポートされている任意の言語(C#、VB、J#)を使用して、PostScript (PS) ファイルを PDF ドキュメントにマージできます。
PS マージを実行するには、いくつかの手順を実行する必要があります。

  1. プライマリPSファイルでPsDocumentを初期化します(例:var document = new PsDocument("first.ps");)。
  2. 結合する追加のPSファイルのパスを含む文字列配列を定義します(例:
1string[] additionalPs = { "second.ps", "third.ps" };
  1. PdfSaveOptionsインスタンスを作成し、必要に応じてAdditionalFontsFolderを設定し、SuppressError = trueを有効にして、重大でない警告をキャプチャします。
  2. 追加のPSファイルをそれぞれドキュメントに追加し(例:foreach (var file in additionalPs) document.AddPage(file);)、結合したPDFを保存します。
1document.Save("merged.pdf", pdfSaveOptions);
  1. SuppressError が true の場合、すべての警告は document.Exceptions に保存されます。保存後にこのコレクションを反復処理して問題を確認できます。


次のコード スニペットは、C# で PS ファイルを PDF ドキュメントに結合する方法を示しています。

 1/ For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
 4// Initialize PS document with the first PostScript file
 5PsDocument document = new PsDocument(dataDir + "input1.ps");
 6
 7// Create an array of PostScript files that will be merged with the first one
 8string[] filesForMerge = new string[] { dataDir + "input2.ps", dataDir + "input3.ps" };
 9
10// If you want to convert Postscript file despite of minor errors set this flag
11bool suppressErrors = true;
12
13//Initialize options object with necessary parameters.
14PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
15// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
16options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
17
18// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
19// But if you need to specify the page size following line
20//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Aspose.Page.Drawing.Size(595, 842));
21
22document.MergeToPdf(dataDir + "outputPDF_out.pdf", filesForMerge, options);
23
24//Review errors
25if (suppressErrors)
26{
27    foreach (Exception ex in options.Exceptions)
28    {
29        Console.WriteLine(ex.Message);
30    }
31}

PS マージについては、 Java および C++ を参照してください。

PdfSaveOptions について考えてみましょう。このクラスを使用すると、PS ファイルを PDF にマージする際に、さまざまな変換パラメータを指定できます。

PS Merger で PS マージ機能をオンラインで評価できます。

サンプルとデータファイルは GitHub からダウンロードできます。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.