Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created January 18, 2021 21:41
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/98ee00c04dffa3583490620b4d2ce029 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/98ee00c04dffa3583490620b4d2ce029 to your computer and use it in GitHub Desktop.
Convert SVG to PDF or XPS Programmatically using C# VB.NET
// Load input SVG file
using (var document = new SVGDocument(Path.Combine(dataDir, "smiley.svg")))
{
// Specify PdfRenderingOptions
var options = new PdfRenderingOptions()
{
// Set Page Setup properties
PageSetup =
{
Sizing = SizingType.FitContent
}
};
using (var device = new PdfDevice(options, dataDir + "smiley_out.pdf"))
{
// Render SVG to PDF
document.RenderTo(device);
}
}
// Load input SVG file
using (var document = new SVGDocument(Path.Combine(dataDir, "smiley.svg")))
{
// Specify XPSRenderingOptions
var options = new XpsRenderingOptions()
{
// Set PDF page size, margins, etc.
PageSetup =
{
AnyPage = new Page(new Size(500, 500))
}
};
using (var device = new XpsDevice(options, dataDir + "smiley_out.xps"))
{
// Render SVG to XPS
document.RenderTo(device);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment