public void SaveToStream(
Stream stream,
SvgSaveOptions options
)
stream
Output stream.
options
Save option. Can be null.
This method will save this SvgDocument to the output stream as a standard SVG document. Use Version to control the SVG version used.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Drawing;
using Leadtools.Forms.DocumentWriters;
using Leadtools.Svg;
using Leadtools.Document.Writer;
public void SvgToStreamExample()
{
// Assume the SVG file is located here
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Page1.svg");
Stream stream = new MemoryStream();
// Load the SVG from file
using (SvgDocument document = SvgDocument.LoadFromFile(srcFileName, null))
{
ShowSvgProperties("Original", document);
// Set the version and save it to a stream
document.Version = SvgVersion.v10;
document.SaveToStream(stream, null);
stream.Position = 0;
}
// Load the SVG from stream and show its properties
using (SvgDocument document = SvgDocument.LoadFromStream(stream, null))
{
ShowSvgProperties("Loaded from stream", document);
}
stream.Dispose();
}
private static void ShowSvgProperties(string message, SvgDocument document)
{
// Prepare it
if (!document.IsFlat)
document.Flat(null);
if (!document.Bounds.IsValid)
document.CalculateBounds(false);
// Show its properties
Console.WriteLine(message);
Console.WriteLine(" Version: " + document.Version);
Console.WriteLine(" Bounds: " + document.Bounds.Bounds);
Console.WriteLine(" Resolution: " + document.Bounds.Resolution);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}