RenderSvgText.vb
C# VB
'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports SystemImports System.IOImports System.DrawingImports System.Collections.GenericImports System.LinqImports System.NumericsImports GrapeCity.Documents.DrawingImports GrapeCity.Documents.TextImports GrapeCity.Documents.ImagingImports GrapeCity.Documents.Svg
'' TBD:Public Class RenderSvgText Public Function GenerateImage( ByVal pixelSize As Size, ByVal dpi As Single, ByVal opaque As Boolean, Optional ByVal sampleParams As String() = Nothing) As GcBitmap
'' Load an SVG with text and tspan: Dim svgString As String = "<svg width='12cm' height='3cm' viewBox='0 0 1000 300' xmlns='http://www.w3.org/2000/svg' version='1.1'>" & " <g font-family='Verdana' font-size='64' >" & " <text x='160' y='180' fill='blue'>Apples are not <tspan font-weight='bold' fill='orange'>oranges</tspan>.</text>" & " </g>" & "</svg>" Using svg = GcSvgDocument.FromString(svgString)
'' Render the SVG image and a border around it: Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi) Using g = bmp.CreateGraphics(Color.White) Dim pt = New PointF(dpi, dpi) g.DrawSvg(svg, pt) Dim sz = svg.GetIntrinsicSize(SvgLengthUnits.Pixels) g.DrawRectangle(New RectangleF(pt, sz), Color.MediumPurple) End Using
'' Done: Return bmp End Using End FunctionEnd Class