Javaを使用してPostScriptファイルをPDFに結合

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

Aspose.Page for Java PS Merger を使用すると、Java 仮想マシンが動作するあらゆる OS 上で、PostScript (PS) ファイルを PDF ドキュメントにマージできます。
PS から PDF へのマージを実行するには、いくつかの手順を実行する必要があります。

  1. 最初の PostScript ファイルから PsDocument のインスタンスを作成します。
  2. 最初の PostScript ファイルとマージする PostScript ファイルの配列を作成します。
  3. PdfSaveOptions を使用して、AdditionalFontsFolderSuppressError ブール値を指定します。
  4. 作成したドキュメントと PS ファイルを結合し、PDF 保存オプションを使用して PDF として保存します。
  5. SuppressErrors 値が true(デフォルト)の場合、EPS ファイルと PDF ドキュメントの結合中に発生したエラーを確認できます。これらのエラーは Exceptions リストに保存されます。


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

 1// Merge several PS files to one PDF document.
 2
 3// Initialize PS document with the first PostScript file
 4PsDocument document = new PsDocument(getDataDir() + "input.ps");
 5
 6// Create an array of PostScript files that will be merged with the first one
 7String[] filesForMerge = new String[] { getDataDir() + "input2.ps", getDataDir() + "input3.ps" };
 8
 9// If you want to convert Postscript file despite of minor errors set this flag
10boolean 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.setAdditionalFontsFolders(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 java.awt.Dimension(595, 842));
20
21document.mergeToPdf(getOutputDir() + "outputPDF_out.pdf", filesForMerge, options);
22
23//Review errors
24if (suppressErrors) {
25    for (Exception ex : options.getExceptions()) {
26        System.out.println(ex.getMessage());
27    }
28}

.NET および C++ の PS マージを参照してください。

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.