diff --git a/Source/SvgDocument.cs b/Source/SvgDocument.cs index b441c5cc1120e68910774d4cff1d1d41081dafe5..cd89dc046b873a1c66017331ae2ca5089b59f4f7 100644 --- a/Source/SvgDocument.cs +++ b/Source/SvgDocument.cs @@ -484,10 +484,10 @@ namespace Svg renderer.SetBoundable(new GenericBoundable(0, 0, bitmap.Width, bitmap.Height)); //EO, 2014-12-05: Requested to ensure proper zooming (draw the svg in the bitmap size, ==> proper scaling) - //EO, 2015-01-09, Added GetDimensions to use its returned size instead of this.Width and this.Height (request of Icarrere). + //EO, 2015-01-09, Added GetDimensions to use its returned size instead of this.Width and this.Height (request of Icarrere). //BBN, 2015-07-29, it is unnecassary to call again GetDimensions and transform to 1x1 //JA, 2015-12-18, this is actually necessary to correctly render the Draw(rasterHeight, rasterWidth) overload, otherwise the rendered graphic doesn't scale correctly - SizeF size = this.GetDimensions(); + SizeF size = this.GetDimensions(); renderer.ScaleTransform(bitmap.Width / size.Width, bitmap.Height / size.Height); //EO, 2014-12-05: Requested to ensure proper zooming out (reduce size). Otherwise it clip the image. @@ -575,12 +575,12 @@ namespace Svg } } - public void Write(Stream stream) + public void Write(Stream stream, bool useBom = true) { - var xmlWriter = new XmlTextWriter(stream, Encoding.UTF8); + var xmlWriter = new XmlTextWriter(stream, useBom ? Encoding.UTF8 : new System.Text.UTF8Encoding(false)); xmlWriter.Formatting = Formatting.Indented; - + xmlWriter.WriteStartDocument(); xmlWriter.WriteDocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null); if (!String.IsNullOrEmpty(this.ExternalCSSHref)) @@ -591,11 +591,11 @@ namespace Svg xmlWriter.Flush(); } - public void Write(string path) + public void Write(string path, bool useBom = true) { using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write)) { - this.Write(fs); + this.Write(fs, useBom); } } }