You can read all the details at: Convert a Postscript PS or EPS file to PDF using Java
Last active
July 3, 2024 15:11
-
-
Save aspose-com-gists/81ab11194ac76cc643fde5787a3f23e3 to your computer and use it in GitHub Desktop.
Convert a Postscript PS or EPS file to PDF Programmatically in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PsDocument object from PostScript file | |
PsDocument document = new PsDocument(dataDir + "input.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); | |
// Convert PS/EPS Postscript file to PDF | |
document.saveAsPdf(dataDir + "PStoPDF.pdf", options); | |
//Review errors | |
if (suppressErrors) { | |
for (Exception ex : options.getExceptions()) { | |
System.out.println(ex.getMessage()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PsDocument object from PostScript file | |
PsDocument document = new PsDocument(dataDir + "input.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, new Dimension(595, 842)); | |
options.setJpegQualityLevel(50); | |
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included. | |
//options.setAdditionalFontsFolders(new String [] {"FONTS_FOLDER"}); | |
// Convert PS/EPS Postscript file to PDF | |
document.saveAsPdf(dataDir + "PStoPDF.pdf", 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