使用 Node.js 将 PS/EPS 文件合并为 PDF
您可以通过免费的在线工具 PS Merger 或 EPS Merger
Aspose.Page for Node.js 通过 C++ PS/EPS 合并功能,可以在 Windows 和 Linux 系统上将封装的 PostScript (EPS) 文件合并为 PDF 文档。
执行 PS/EPS 到 PDF 合并只需执行以下步骤:
- 调用 AsposePSMergeToPdf,并将文件名数组、结果文件名和 SuppressError 布尔值传递给它。
结果 JSON 文件中的 fileNameResult 包含文件名。
如果 SuppressErrors 值为 true(默认情况下),则可以查看 EPS 合并为 PDF 时抛出的错误。
以下代码片段展示了如何在 NodeJS 中将 EPS 文件合并为 PDF 文档:
1const AsposePage = require('asposepagenodejs');
2
3const ps_files = "./data/program_01.ps,./data/PAGENET-361-10.eps";
4
5console.log("Aspose.Page for Node.js via C++ examples.");
6
7AsposePage().then(AsposePageModule => {
8
9 //PSMergeToPdf - convert to postscript to image
10 const JSON = AsposePageModule.AsposePSMergeToPdf(ps_files,"PsMergedToPdfResult.pdf",true);
11 console.log("PSMergeToPdf => %O", JSON.errorCode == 0 ? JSON.fileNameResult : JSON.errorText);
12},
13 reason => {console.log(`The unknown error has occurred: ${reason}`);}
14);
让我们来考虑一些参数。
- SuppressError 控制 EPS 到 PDF 合并过程中出现非严重错误时的行为。如果该值为 true,则可以在合并后在 Exceptions 字段中查看此类错误列表。默认值为 true。