Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-gists/95e5ad7097b65d5eead075712e411fa2 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/95e5ad7097b65d5eead075712e411fa2 to your computer and use it in GitHub Desktop.
Merge PS/EPS to PDF with Java

Merge PS Examples

These code snippets demonstrate how to merge multiple PostScript (PS) files into a single PDF document using Aspose.Page for Java. This is useful for combining print jobs or consolidating documents for archiving.

Key Use Cases

  • Merge several PS files into one PDF document.
  • Automate PS merging for batch processing.

How to Run Examples

  1. Reference Aspose.Page for Java in your project.
  2. Copy the required code snippet into your project.
  3. Download a temporary license and set it up as described here or use a paid license.
  4. Run the example.

Restrictions

In evaluation mode, total length of merged PS/EPS files is limited to 1Mb. Apply a valid license to use full functionality.

Related Documentation

See Merge PS Files in the official documentation for more details.

Related Resources

Requirements

  • Java 8 or higher
  • Aspose.Page for Java library
Aspose.Page for Java – Merge PS Examples
// Merge several EPS files to one PDF document.
// Learn more: https://docs.aspose.com/page/java/merge/ps/
// Initialize PS document with the first EPS file
PsDocument document = new PsDocument(getDataDir() + "input.eps");
// Create an array of PostScript files that will be merged with the first one
String[] filesForMerge = new String[] { getDataDir() + "input2.eps", getDataDir() + "input3.eps" };
// If you want to convert Postscript file despite of minor errors set this flag
boolean suppressErrors = true;
//Initialize options object with necessary parameters.
PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
options.setAdditionalFontsFolders(new String[] { "{FONT_FOLDER}" });
// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
// But if you need to specify the page size following line
//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new java.awt.Dimension(595, 842));
document.mergeToPdf(getOutputDir() + "outputPDF_out.pdf", filesForMerge, options);
//Review errors
if (suppressErrors) {
for (Exception ex : options.getExceptions()) {
System.out.println(ex.getMessage());
}
}
// Merge several PS files to one PDF document.
// Learn more: https://docs.aspose.com/page/java/merge/ps/
// Initialize PS document with the first PostScript file
PsDocument document = new PsDocument(getDataDir() + "input.ps");
// Create an array of PostScript files that will be merged with the first one
String[] filesForMerge = new String[] { getDataDir() + "input2.ps", getDataDir() + "input3.ps" };
// If you want to convert Postscript file despite of minor errors set this flag
boolean suppressErrors = true;
//Initialize options object with necessary parameters.
PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
options.setAdditionalFontsFolders(new String[] { "{FONT_FOLDER}" });
// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
// But if you need to specify the page size following line
//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new java.awt.Dimension(595, 842));
document.mergeToPdf(getOutputDir() + "outputPDF_out.pdf", filesForMerge, options);
//Review errors
if (suppressErrors) {
for (Exception ex : options.getExceptions()) {
System.out.println(ex.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment