public static SvgDocument LoadFromFile(string fileName,SvgLoadOptions options)
fileName
Path to the SVG file on disk
options
Options to use during load. If this parameter is null, then a default SvgLoadOptions object will be used.
The SvgDocument object this method creates.
To get and set information about the document's bounds and resolution, refer to SVG Size, Bounds and Flat.
This example will use Leadtools.Document.Writer.DocumentWriter to create a PDF file from SVG files.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.Forms.DocumentWriters;using Leadtools.Svg;using Leadtools.Document.Writer;public void SvgLoadFromFileExample(){// Create the SVG pages we will be usingstring srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.doc");string outDir = Path.Combine(LEAD_VARS.ImagesDir, "TempSvgPages");string dstFileName = Path.Combine(outDir, "Example.pdf");if (!Directory.Exists(outDir))Directory.CreateDirectory(outDir);int pageCount = CreateSvgPages(srcFileName, outDir);// Create a PDF document using Document Writervar documentWriter = new Leadtools.Document.Writer.DocumentWriter();documentWriter.BeginDocument(dstFileName, Leadtools.Document.Writer.DocumentFormat.Pdf);string svgPageTemplateName = Path.Combine(outDir, "Page{0}.svg");for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++){// Load this SVGstring pageFileName = string.Format(svgPageTemplateName, pageNumber);Console.WriteLine("Loading {0}", pageFileName);using (SvgDocument svgDocument = SvgDocument.LoadFromFile(pageFileName, null)){// Check if we need to flat itif (!svgDocument.IsFlat)svgDocument.Flat(null);if (!svgDocument.Bounds.IsValid)svgDocument.CalculateBounds(false);// Add it to the document writerConsole.WriteLine("Adding ...");DocumentWriterSvgPage svgPage = new DocumentWriterSvgPage();svgPage.SvgDocument = svgDocument;documentWriter.AddPage(svgPage);}}// Finish upConsole.WriteLine("Finishing ...");documentWriter.EndDocument();}private static int CreateSvgPages(string srcFileName, string outDir){// Extract all the pages from the source file as SVGusing (var codecs = new RasterCodecs()){// Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300;// Get all the files from input directoryint pageCount = codecs.GetTotalPages(srcFileName);for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++){using (SvgDocument svgDocument = codecs.LoadSvg(srcFileName, pageNumber, null) as SvgDocument){// Save it to diskstring dstFileName = Path.Combine(outDir, Path.Combine(string.Format("Page{0}.svg", pageNumber)));Console.WriteLine("Saving to {0}", dstFileName);svgDocument.SaveToFile(dstFileName, null);}}return pageCount;}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}