For more details, please visit Convert SVG to EPS or PS PostScript File using C#
Last active
July 19, 2022 14:16
-
-
Save aspose-com-gists/ada9064015be0ced399a09c1ec80a267 to your computer and use it in GitHub Desktop.
Convert SVG to EPS or PS PostScript file Programmatically using C#
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 a MemoryStream object | |
MemoryStream stream = new MemoryStream(); | |
// Initialize an SVG document from a file | |
SVGDocument document = new SVGDocument("light.svg"); | |
// Initialize an instance of PdfRenderingOptions class | |
PdfRenderingOptions pdfRenderingOptions = new PdfRenderingOptions(); | |
pdfRenderingOptions.PageSetup.AnyPage = new Page(new Size(500, 500), new Margin(10, 10, 10, 10)); | |
// Initialize an instance of PdfDevice class | |
IDevice device = new PdfDevice(pdfRenderingOptions, stream); | |
// Render SVG to PDF, send the document to the rendering device | |
document.RenderTo(device); | |
String printerName = "Microsoft XPS Document Writer"; | |
String psOutFileName = "psOut.ps"; | |
Document pdf = new Document(stream); | |
// Create the printer settings | |
PrinterSettings printerSettings = new PrinterSettings(); | |
printerSettings.PrinterName = (printerName); | |
printerSettings.PrintToFile = (true); | |
printerSettings.PrintFileName = (dataDir + psOutFileName); | |
// Specify page settings | |
PageSettings pageSettings = new PageSettings(); | |
pageSettings = printerSettings.DefaultPageSettings; | |
pageSettings.Margins = (new Margins(0, 0, 0, 0)); | |
pageSettings.Color = (true); | |
PdfViewer viewer = new PdfViewer(); | |
viewer.BindPdf(pdf); | |
viewer.AutoResize = (true); | |
viewer.AutoRotate = (true); | |
viewer.PrintPageDialog = (false); | |
// Convert the SVG to EPS or PS file | |
viewer.PrintDocumentWithSettings(pageSettings, printerSettings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment