Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 16, 2022 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/44dac282b63a6fd1d7c01da8a6e8784c to your computer and use it in GitHub Desktop.
Save aspose-com-gists/44dac282b63a6fd1d7c01da8a6e8784c to your computer and use it in GitHub Desktop.
Convert EPS or PS to SVG in C# | Postscript to SVG Image in .NET
// Initialize a MemoryStream class object
Stream stream = new MemoryStream();
// Initialize PostScript input stream
System.IO.FileStream psStream = new System.IO.FileStream("input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
Aspose.Page.EPS.PsDocument document = new Aspose.Page.EPS.PsDocument(psStream);
// If you want to convert Postscript file despite of minor errors set this flag
bool suppressErrors = true;
// Initialize options object with necessary parameters.
Aspose.Page.EPS.Device.PdfSaveOptions options = new Aspose.Page.EPS.Device.PdfSaveOptions(suppressErrors);
// Initialize a PdfDevice class object
Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(stream, new System.Drawing.Size(595, 842));
// Convert the EPS file to PDF format
document.Save(device, options);
// Load the intermediary PDF document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(stream);
// Instantiate an object of SvgSaveOptions class
Aspose.Pdf.SvgSaveOptions saveOptions = new Aspose.Pdf.SvgSaveOptions();
// Save the output file as SVG image
pdfDocument.Save("output.svg", saveOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment