RenderSvgz.cs
// 完毕:
using System;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Svg;
using GCTEXT = GrapeCity.Documents.Text;
using GCDRAW = GrapeCity.Documents.Drawing;
using DsPdfWeb.Demos.Common;

namespace DsPdfWeb.Demos
{
    // This sample shows how to render an SVGZ (compressed SVG) image.
    // The SVG art used in this sample is from freesvg.org.
    public class RenderSvgz
    {
        public int CreatePDF(Stream stream)
        {
            var svgPath = Path.Combine("Resources", "SvgMisc", "Smiling-Girl.svgz");
            using var svg = GcSvgDocument.FromSvgz(File.ReadAllBytes(svgPath));

            // Render the image and a border around it:
            var doc = new GcPdfDocument();
            var g = doc.NewPage().Graphics;
            var pt = new PointF(72, 72);
            g.DrawSvg(svg, pt);
            var sz = svg.GetIntrinsicSize(SvgLengthUnits.Points);
            g.DrawRectangle(new RectangleF(pt, sz), Color.MediumPurple);

            // Done:
            doc.Save(stream);
            return doc.Pages.Count;
        }
    }
}