/// <summary> /// Exports the specified model to a stream. /// </summary> /// <param name="model">The model.</param> /// <param name="stream">The output stream.</param> /// <param name="width">The width (points).</param> /// <param name="height">The height (points).</param> /// <param name="isDocument">if set to <c>true</c>, the xml headers will be included (?xml and !DOCTYPE).</param> /// <param name="textMeasurer">The text measurer.</param> public static void Export(PlotModel model, Stream stream, double width, double height, bool isDocument, IRenderContext textMeasurer) { using (var rc = new SvgRenderContext(stream, width, height, true, textMeasurer, model.Background)) { model.Update(); model.Render(rc, width, height); rc.Complete(); rc.Flush(); } }
/// <summary> /// Exports the specified model to a stream. /// </summary> /// <param name="model">The model.</param> /// <param name="stream">The output stream.</param> /// <param name="width">The width (points).</param> /// <param name="height">The height (points).</param> /// <param name="isDocument">if set to <c>true</c>, the xml headers will be included (?xml and !DOCTYPE).</param> /// <param name="textMeasurer">The text measurer.</param> /// <param name="useVerticalTextAlignmentWorkaround">Whether to use the workaround for vertical text alignment</param> public static void Export(IPlotModel model, Stream stream, double width, double height, bool isDocument, IRenderContext textMeasurer = null, bool useVerticalTextAlignmentWorkaround = false) { if (textMeasurer == null) { textMeasurer = new PdfRenderContext(width, height, model.Background); } using (var rc = new SvgRenderContext(stream, width, height, isDocument, textMeasurer, model.Background, useVerticalTextAlignmentWorkaround)) { model.Update(true); model.Render(rc, width, height); rc.Complete(); rc.Flush(); } }
/// <summary> /// Exports to string. /// </summary> /// <param name="model">The model.</param> /// <param name="width">The width (points).</param> /// <param name="height">The height (points).</param> /// <param name="textMeasurer">The text measurer.</param> /// <param name="isDocument">if set to <c>true</c>, the xml headers will be included (?xml and !DOCTYPE).</param> /// <returns> /// The plot as a svg string. /// </returns> public static string ExportToString(PlotModel model, double width, double height, bool isDocument = false, IRenderContext textMeasurer = null) { string svg; using (var ms = new MemoryStream()) { var svgrc = new SvgRenderContext(ms, width, height, isDocument, textMeasurer); model.Update(); model.Render(svgrc); svgrc.Complete(); svgrc.Flush(); ms.Flush(); ms.Position = 0; var sr = new StreamReader(ms); svg = sr.ReadToEnd(); } return(svg); }
/// <summary> /// Exports to string. /// </summary> /// <param name="model">The model.</param> /// <param name="width">The width (points).</param> /// <param name="height">The height (points).</param> /// <param name="textMeasurer">The text measurer.</param> /// <param name="isDocument">if set to <c>true</c>, the xml headers will be included (?xml and !DOCTYPE).</param> /// <returns> /// The plot as a svg string. /// </returns> public static string ExportToString(PlotModel model, double width, double height, bool isDocument = false, IRenderContext textMeasurer = null) { string svg; using (var ms = new MemoryStream()) { var svgrc = new SvgRenderContext(ms, width, height, isDocument, textMeasurer); model.Update(); model.Render(svgrc); svgrc.Complete(); svgrc.Flush(); ms.Flush(); ms.Position = 0; var sr = new StreamReader(ms); svg = sr.ReadToEnd(); } return svg; }