SvgSpecArt.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
'' Use GcSvgDocument to render a few images used as illustrations'' in the SVG spec.Public Class SvgSpecArt Function CreatePDF(ByVal stream As Stream) As Integer '' Load images from resources: Dim fnames = New List(Of String)() From {"dash-path.svg", "opacity.svg", "paths.svg", "shadowstyle.svg", "units.svg"} Dim images = New List(Of (String, GcSvgDocument))() For Each f In fnames images.Add((f, GcSvgDocument.FromFile(Path.Combine("Resources", "SvgSpecArt", f)))) Next
Const margin As Single = 36 Const gapy As Single = 18 Dim ip = New PointF(margin, margin)
'' Render the images: Dim doc = New GcPdfDocument() Dim g = doc.NewPage().Graphics For i = 0 To images.Count - 1 Dim svg = images(i).Item2 Dim s = svg.GetIntrinsicSize(SvgLengthUnits.Points) g.DrawSvg(svg, ip) ip.Y += s.Height + gapy Next
'' Done: doc.Save(stream) '' Dispose images after saving the PDF: images.ForEach(Sub(t_) t_.Item2.Dispose()) Return doc.Pages.Count End FunctionEnd Class