Solved

Streaming SVG in an ASPX page

Posted on 2006-11-18
11
478 Views
Last Modified: 2010-04-16
Hi All,

I need some help.

I have an ASPX Page. I would like to stream a simple polygon in SVG.

I'v tried MANY combinations but with no luck
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            Response.ContentType = "image/svg+xml";
            Response.Write("<?xml version=\"1.0\" standalone=\"no\"?>");
            Response.Write("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">");
            Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400 xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
            Response.Write("<desc>Example polygon01 - star and hexagon</desc>");
            Response.Write("  <rect x=\"1\" y=\"1\" width=\"1198\" height=\"398\" fill=\"none\" stroke=\"blue\" stroke-width=\"2\" />");
            Response.Write("   <polygon fill=\"red\" stroke=\"blue\" stroke-width=\"10\" points=\"350,75  379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161\" />");
            Response.Write("</svg>");
            Response.End();
        }

I hav tried changing the type from image to text, taking out the XML and DOCTYPE and no luck.
I have the adobe viewer installed on IE6.


Any help appreciated
0
Comment
Question by:Pete2003
  • 7
  • 4
11 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971081
Your svg is not well formed.
It may be the namespaces you have eclared.

This works ;

private void Page_Load(object sender, System.EventArgs e)
            {

                  Response.AddHeader("Content-Type","image/svg-xml");
                  Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400\">");
                  Response.Write("<desc>Example polygon01 - star and hexagon</desc>");
                  Response.Write("  <rect x=\"1\" y=\"1\" width=\"1198\" height=\"398\" fill=\"none\" stroke=\"blue\" stroke-width=\"2\" />");
                  Response.Write("   <polygon fill=\"red\" stroke=\"blue\" stroke-width=\"10\" points=\"350,75  379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161\" />");
                  Response.Write("</svg>");
                  Response.End();


            }
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971090
OK.
I have found the problem it is here :

 Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400 xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");

The attribute viewBox is not closed correctly you need it to be this :

 Response.Write("<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971100
If you look in your browser when you mouse-over the page the svg plug-in has actually set the status bar test to :

not well formed : line 1, column 195.

However, it just shows this as info, not and error or even a warning.
0
 

Author Comment

by:Pete2003
ID: 17971225
Thanks for the replies, unfortunatelly nothing worked ...

I tried copy & paste from your 1st reply, al I get is a blank SVG plugin window.
I also tried fixing the viewbox window, no change
ALso I get nothing on the status line when I mouse over.

0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971389
If you look at this article and examples can you see the graphics ?

http://www.4guysfromrolla.com/webtech/091401-1.shtml
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Pete2003
ID: 17971559
Ok this is very weird ...

The 1st demo shows nothing
<%Response.AddHeader "Content-Type","image/svg-xml"%>
<svg>
  <rect x="10" y="10" width="100" height="100"/>
</svg>



The 2nd one ...
<%Response.AddHeader "Content-Type","image/svg-xml"%>
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 200
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />
  </defs>
  <desc>Example toap01 - simple text on a path</desc>

  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="42.5" fill="blue" >
    <textPath xlink:href="#MyPath">
      <%
      Dim title
      title = "We go up, then we go down, then up again."
      If Request("title") <> "" Then
         title = Request("title")
      End If
      Response.Write title
      %>
    </textPath>
  </text>

  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Works 100% ... I tried uninstalling/rebooting and it's still the same
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17971616
Very weird....
0
 

Author Comment

by:Pete2003
ID: 17985408
It turns out that none of the SVGs are visible on the same machie as VS2005 is installed and I'm debugging from, but once I connect to the IIS site from a remote machine then I can see the SVG.

Does anybody know what to do to get it visible on the same machine?
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17985838
There was a vulnerability in the svg rendering library in windows a while ago.
There was a delay in the patch from microsoft and the interim patch de-registered the faulty dll.
I do not know if this dll is used by the adobe plug-in at all but it may be that you need to patch-up your machine to get this fixed.
Or you could try re-registering the dll to see if it helps :

regsvr32 "%ProgramFiles%\Common Files\Microsoft Shared\VGX\vgx.dll"
0
 

Author Comment

by:Pete2003
ID: 17986492
That worked 100% thanks :)
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17986769
OK. However, you should make sure you are fully patched.
The Vulnerability in the SVG dll was a zero-day, remote code execution vulnerability.
If you are not patched you could get a nasty shock.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now