翻譯|使用教程|編輯:張瑩心|2021-10-13 15:54:16.560|閱讀 344 次
概述:SVG 文件是常用的,因為它們可以在不損失圖像質(zhì)量的情況下進行縮放。您可以使用 C# 以編程方式將SVG文件轉(zhuǎn)換為EPS或PS Postscript 文件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.SVG for .NET API 旨在創(chuàng)建、操作或?qū)?SVG 文件轉(zhuǎn)換為支持的文件格式。感興趣的朋友可點擊下方按鈕下載最新版。
SVG 到 EPS 或 PS 的轉(zhuǎn)換是一個兩步過程。首先將 SVG 圖像渲染為 PDF 格式,然后將 PDF 文件轉(zhuǎn)換為 EPS 或 PS PostScript 格式。因此,請從New Releases下載Aspose.SVG for .NET和 Aspose.PDF for .NET API的 DLL 文件,或使用以下 NuGet 安裝命令:
PM> Install-Package Aspose.SVGPM> Install-Package Aspose.PDF
您可以通過以下步驟將 SVG 圖像轉(zhuǎn)換為 EPS 或 PS PostScript 文件:
// 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);
如果你想試用Aspose的全部完整功能,可聯(lián)系在線客服獲取30天臨時授權(quán)體驗。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn