RenderSvg.vb
C# VB
'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports SystemImports System.IOImports System.DrawingImports System.LinqImports System.Collections.GenericImports GrapeCity.Documents.PdfImports GrapeCity.Documents.Svg
'' This short sample shows how to measure and render an SVG image.'' Note that when an SVG is rendered on GcPdfGraphics, it is NOT rasterized,'' so the image quality is preserved if the SVG is scaled up or down.Public Class RenderSvg Function CreatePDF(ByVal stream As Stream) As Integer '' Load the SVG: Dim svgPath = Path.Combine("Resources", "SvgClipArt", "Smiling-Girl.svg") Using svg = GcSvgDocument.FromFile(svgPath) '' Measure and render the image: Dim doc = New GcPdfDocument() Dim g = doc.NewPage().Graphics Dim pt = New PointF(g.Resolution, g.Resolution) Dim rc = New RectangleF(pt, svg.GetIntrinsicSize(SvgLengthUnits.Points)) '' Draw the SVG and a border around it: g.DrawSvg(svg, pt) g.DrawRectangle(rc, Color.DarkGray)
'' Done: doc.Save(stream) Return doc.Pages.Count End Using End FunctionEnd Class