Jump to content
Software FX Community

render stream SVG


laros79

Recommended Posts

Dear All - I have a problem in 2 days not solve.. :(. the background: we want to save all stream chart into blob database column. I really appreciate your help. the situation is:when we are executing method RenderToStream in web projects, it's fine... ,but when i create library project C# to run method RenderToStream then showing error message: "Object reference not set to an instance of an object."

the error stack trace is: at ChartFX.WebForms.Writer.Svg.SvgWriter.b(Stream A_0, OutputText A_1, OutputInfo A_2) at ChartFX.WebForms.Internal.OutputScript.b(Stream A_0, OutputText A_1, OutputInfo A_2) at ChartFX.WebForms.Chart.a(Stream A_0, IOutputWriter A_1, OutputText A_2, OutputText A_3, OutputInfo A_4) at ChartFX.WebForms.Chart.a(String A_0, Stream A_1, TextWriter A_2, TextWriter A_3) at ChartFX.WebForms.Chart.RenderToStream(Stream content, TextWriter imgMap, TextWriter htmlTag) 

below is snapshot code:Chart chart1 = new Chart();

chart1.ImageSettings.ToolTips =

ImageToolTipStyle.AsTitle; chart1.ID = "SalesChart";

 

System.Text.StringBuilder strBuilder1 = new System.Text.StringBuilder("");

System.Text.

StringBuilder strBuilder2 = new System.Text.StringBuilder("");System.IO.StringWriter strWriter1 = new System.IO.StringWriter(strBuilder1);

System.IO.

StringWriter strWriter2 = new System.IO.StringWriter(strBuilder1);System.IO.Stream svgStream = new System.IO.MemoryStream();

svgStream.Position = 0;

chart1.OutputWriter = new ChartFX.WebForms.Writer.Svg.SvgWriter();

chart1.RenderToStream(svgStream, strWriter1, strWriter2);

 

svgStream.Position = 0;

System.Xml.XmlTextReader svgReader = new XmlTextReader(svgStream);

svgReader.Namespaces =

true;XmlDocument doc = new XmlDocument();

doc.Load(svgReader);

XmlElement svgRoot = doc.DocumentElement;

svgRoot.Attributes.RemoveNamedItem(

"xml:space");XmlAttribute aspectAttr = doc.CreateAttribute("preserveAspectRatio");aspectAttr.Value = "none";

svgRoot.Attributes.Append(aspectAttr);

svgStream.Close();

strWriter1.Close();

strWriter2.Close();

Link to comment
Share on other sites

Thanks Frank, but when i did it on previosu version 6.0 (chartFX.Internet) .. it was good and works... is that any reason why it must need httpcontext.current whenever we don't need to check whether using ActiveX control or not. because if we export it into SVG. it should be processing SVG stream without check ActiveX in httpContext, right?

do you have any idea to manipulate it? or should i go back using previuos version?

 again thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...