protected SvgDocument(SerializationInfo info,StreamingContext context)
info
The data needed to serialize or deserialize an object.
context
The source and destination of a given serialized stream.
The SvgDocument class supports standard .NET serialization. Serialization of a SvgDocument is the process of converting the state of a Leadtools.RasterImage object into a form that can be persisted or transported. The complement of serialization is deserialization, which converts a stream into an Leadtools.RasterImage object. Together, these processes allow the image data to be easily stored and transferred.
When you serialize a SvgDocument object, all the data inside the object is saved. The SvgDocument can be reconstructed back to its original state from the stream.
This example will show how to serialize and deserialize a SVG document.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.Forms.DocumentWriters;using Leadtools.Svg;using Leadtools.Document.Writer;public void SvgDocumentSerializationExample(){SvgDocument document = null;// Load a page from a document file as SVGstring srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf");using (var codecs = new RasterCodecs()){// Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300;document = codecs.LoadSvg(srcFileName, 1, null) as SvgDocument;}// Prepare itif (!document.IsFlat)document.Flat(null);if (!document.Bounds.IsValid)document.CalculateBounds(false);// Show its propertiesConsole.WriteLine("Before serialization");Console.WriteLine("Bounds: " + document.Bounds.Bounds);Console.WriteLine("Resolution: " + document.Bounds.Resolution);// Serialize (save) it to a streamvar stream = new MemoryStream();var formatter = new BinaryFormatter();formatter.Serialize(stream, document);stream.Position = 0;// Get rid of the documentdocument.Dispose();// Now de-serailize (load) it back from the stream and show its propertiesdocument = formatter.Deserialize(stream) as SvgDocument;Console.WriteLine("After de-serialization");Console.WriteLine("Bounds: " + document.Bounds.Bounds);Console.WriteLine("Resolution: " + document.Bounds.Resolution);document.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}