For more details, please visit Convert EPS or PS PostScript File to an SVG Image using Java
Last active
December 23, 2021 05:56
-
-
Save aspose-com-gists/babc9d668d2de044ae835145ea6bc86e to your computer and use it in GitHub Desktop.
Convert EPS or PS PostScript File to an SVG Image (Scalable Vector Graphic) using 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 ByteArrayOutputStream to hold intermediary PDF file. | |
final ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); | |
// Initialize EPS or PS PostScript input stream | |
FileInputStream psStream = new FileInputStream("input.ps"); | |
// Declare PsDocument class object. | |
PsDocument document = new PsDocument(psStream); | |
// 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); | |
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"}); | |
// If you need to specify size and image format use following line | |
PdfDevice device = new PdfDevice(pdfStream, new Dimension(595, 842)); | |
// Convert EPS or PS Postscript file to PDF | |
document.save(device , options); | |
// Load the intermediary PDF file | |
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(pdfStream.toByteArray()); | |
// Instantiate an object of SvgSaveOptions | |
com.aspose.pdf.SvgSaveOptions saveOptions = new com.aspose.pdf.SvgSaveOptions(); | |
// Convert the EPS or PS file to an SVG file | |
doc.save("output.svg", saveOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment