Created
February 10, 2021 21:27
-
-
Save aspose-com-gists/d58bf88bb1bca6af7affe9383e3a015b to your computer and use it in GitHub Desktop.
Load, Save or Merge SVG Images to PDF XPS JPG PNG Programmatically in C#
This file contains hidden or 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
// Specify the file path to input SVG | |
string document = Path.Combine(dataDir, "QBezier.svg"); | |
// OR specify the URL to load the SVG image | |
var documentUrl = new Url("https://docs.aspose.com/svg/net/drawing-basics/svg-path-data/owl.svg"); | |
// Load an SVG document from a file or URL | |
var document = new SVGDocument(document) |
This file contains hidden or 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 SVG documents from files to merge later | |
using (var document1 = new SVGDocument(Path.Combine(DataDir, "owl.svg"))) | |
using (var document2 = new SVGDocument(Path.Combine(DataDir, "conclusion.svg"))) | |
using (var document3 = new SVGDocument(Path.Combine(DataDir, "Lineto.svg"))) | |
{ | |
// Create an instance of SvgRenderer | |
using (var renderer = new SvgRenderer()) | |
{ | |
// Create an instance of PdfDevice | |
using (var device = new PdfDevice(Path.Combine(OutputDir, "result.pdf"))) | |
{ | |
// Merge all SVG documents to PDF | |
renderer.Render(device, document1, document2, document3); | |
} | |
} | |
} |
This file contains hidden or 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
// Set a full (complete) path for SVG document saving | |
var url = new Url(Path.Combine(OutputDir, "Lineto_out.svg"), Directory.GetCurrentDirectory()); | |
// Save SVG to a file | |
document.Save(documentPath); | |
// OR Save SVG to the Url | |
document.Save(url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment