使用 Java 将 EPS 文件合并为 PDF

您可以通过免费在线工具 EPS 合并器

检查 Aspose.Page EPS 合并器的质量并查看结果。

Aspose.Page for Java EPS 合并器允许在任何支持 Java 虚拟机的操作系统上将封装的 PostScript (EPS) 文件合并为 PDF 文档。
执行 EPS 到 PDF 合并需要执行以下几个步骤:

  1. 从第一个 EPS 文件创建 PsDocument 实例。
  2. 创建一个将与第一个 EPS 文件合并的 EPS 文件数组。
  3. 使用 PdfSaveOptions 指定 AdditionalFontsFolderSuppressError 布尔值。
  4. 将 EPS 文件与创建的文档合并,并使用 PDF 保存选项将其保存为 PDF。
  5. 如果 SuppressErrors 值为 true(默认情况下),则可以查看将 EPS 文件合并为 PDF 文档时引发的错误,并将其保存在 Exceptions 列表中。


以下代码片段展示了如何在 Java 中将 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(getDataDir() + "input.eps");
 5
 6// Create an array of PostScript files that will be merged with the first one
 7String[] filesForMerge = new String[] { getDataDir() + "input2.eps", getDataDir() + "input3.eps" };
 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}

请参阅 .NETC++ 中的 EPS 合并。

我们来看一下 PdfSaveOptions。使用此类,我们可以在将 EPS 文件合并为 PDF 时指定不同的转换参数。

在我们的 EPS 合并器 上在线评估 EPS 合并。

您可以从 GitHub 下载示例和数据文件。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.