RenderSvg.vb
''
'' This code is part of Document Solutions for PDF .NET demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Linq
Imports System.Collections.Generic
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Svg
Imports GCTEXT = GrapeCity.Documents.Text
Imports GCDRAW = GrapeCity.Documents.Drawing

'' 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 Function
End Class