70001101 Is it possible to get an SVG output as a stream

Article 70001101
Type HowTo
Product Engine
Version 7
Date Added 6/15/2017
Fixed 7.7012.0.1 (6/15/2017)
Submitted by Bruce Jacobs

Summary

Is it possible to get an SVG output as a stream?

Solution

It is possible, using the vdPrint object and StreamExport method like:

   vdPrint prn = vdFCSource.BaseControl.ActiveDocument.ActiveLayOut.Printer;
   prn.PrinterName ="file.svg";  // just specify that this will be a SVG
   prn.PrintExtents();
   prn.PrintScaleToFit();
   // you need to add RenderFormats.dll to your project’s references
   System.IO.MemoryStream SVGstream = VectorDraw.Render.PrinterRender.StreamExport(new RenderFormats.SvgRender(), vdFCSource.BaseControl.ActiveDocument, prn, @"C:\test\"); 
Then you can get this stream into a file on disk like:
   // Just to see the SVG stream from an SVG viewer,  write it to disk. 
   FileStream fileStream = File.Create(@"C:\just_for_Test\my2.svg");
   fileStream.Write(SVGstream .GetBuffer(),0,(int)SVGstream .Length);
   fileStream.Close();     

Send comments on this topic.