Python を使って EPS ファイルを PDF に結合

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

Aspose.Page for Python の .NET EPS Merger を使用すると、Python 仮想マシンが動作するあらゆるオペレーティングシステムで、Encapsulated PostScript (EPS) ファイルを PDF ドキュメントに結合できます。

EPS から PDF への結合を実行するには、いくつかの手順が必要です。

  1. 最初の入力 EPS ファイルの入力ストリームを初期化します。
  2. 出力 PDF ドキュメントの出力ストリームを初期化します。
  3. 最初の EPS ファイルと結合する EPS ファイルの配列を作成します。
  4. 作成した入力ストリームから PsDocument のインスタンスを作成します。
  5. PdfSaveOptions を使用して、AdditionalFontsFolderSuppressError ブール値を指定します。
  6. 先ほど作成した出力ストリームから PdfDevice のインスタンスを作成します。
  7. 作成したドキュメントと EPS ファイルを結合し、指定した PDF 保存オプションを使用して PDF として保存します。


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

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python
 2
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_document_merging()
 5# Initialize a PDF output stream
 6pdf_stream = open(data_dir + "outputPDF_out.pdf", "wb")
 7# Initialize the first PostScript file input stream
 8ps_stream = open(data_dir + "input.eps", "rb",)
 9document = PsDocument(ps_stream)
10
11# Create an array of PostScript files that will be merged with the first one
12files_for_merge = [ data_dir + "input2.eps", data_dir + "input3.eps" ]
13
14# If you want to convert the Postscript file despite of minor errors set this flag
15suppress_errors = True
16
17# Initialize options object with the necessary parameters.
18options = PdfSaveOptions(suppress_errors)
19# If you want to add a special folder where fonts are stored. Default fonts folder in OS is always included.
20options.additional_fonts_folders = [ """{FONT_FOLDER}""" ]
21
22# Default page size is 595x842 and it is not mandatory to set it in PdfDevice
23device = PdfDevice(pdf_stream)
24# But if you need to specify size and image format use following line
25#Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream, new aspose.pydrawing.Size(595, 842));
26
27try:
28    document.merge(files_for_merge, device, options)
29finally:
30    ps_stream.close()
31    pdf_stream.close()

EPSファイルの結合については、 .NETJavaC++をご覧ください。

EPSファイルをPDFに結合する際に、さまざまな変換パラメータを設定できる PdfSaveOptionsについて考えてみましょう。

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

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

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.