|
It actually draws the SVG, but the file could not be opened with "Edge", "Chrome" or "FireFox".
But "Inkscape" could open it, so I could check its validity. After resaving the SVG the Image was displayed correctly using the Browser.
The ViewBox is not set, and even if you set it, it is not recognized because the viewBox attribute is parsed incorrectly (it is a lower case B but should be an upper case B).
Why should I set a ViewBox? So that the browser or SVG editor knows how to display the image if no size is defined externally (e.g. by the control).
Edit: After some debugging I actually found a bug -> X.ToString() does not use an IFormatProvider - I live in Austria and formatting decimal numbers would result in the format "0,0" instad of "0.0".
-- modified 20-Nov-20 12:03pm.
|
|
|
|
|
I am not able to get SVG ActiveX library and the code gives me error.
Can you help me with this as I am new to SVG and trying to learn it!
|
|
|
|
|
I just tried the chm file, but it didn't produce help pages. Only headings.
|
|
|
|
|
Works fine for me. You have to "unblock" the file first. Right-click the CHM file and select "Properties". You should see an "unblock" option at the bottom of the dialog.
|
|
|
|
|
Dear Ben,
I came across this article while trying to add SVG printing functionality to my library.
Previously I use GDI to construct an image and then print it.
However it will be very big to send across the network.
Off course I do not want the upper layer to be changed to much.
The SvgNet looks like a perfect solution for me .
However , in my library there is a bit of code like this :
Bitmap img = new Bitmap(1, 1);
img.SetResolution(dpiX, dpiY);
Graphics g = Graphics.FromImage(img);
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.High;
I do not know how to do the same thing with SVGNet library . Some thing like :
SvgGraphics g = SvgGraphics.FromImage(img)
Can you help ?
REGARDS,
TOAN NGUYEN
|
|
|
|
|
|
|
The link to the project home page does not work. Would you be able to host the project on GitHub, CodePlex or similar? It appears that the domain name has expired.
Pie Man
|
|
|
|
|
Some countries use "," instead of "." for decimal point (for example the Nordic countries). When writing numbers to xml this must be taken into account, since the .ToString() method use the users locale. The easiest way is to always use the System.Xml.XmlConvert.ToString() when writing XML.
Whoever decided to use "," for decimal point should have had a brain scan... Anyway, the programmers in these countries should go together the change it. For sure non-programmers have probably not even reflected on the difference. It must cost more than the Y2k-bug a year from of all the bugs it generates...
|
|
|
|
|
I compile and run SvgDocTest from the sample code and always get a fatal error (detailed below) when assigning a file name to the SRC property of AxSVGCtl. (Line 235 in Form1.cs.) I have tried a number of different svg files, all of which successfully display in other svg viewers. I have also searched extensively for info on this error on MSDN and other sites, but without any luck, although a lot of developers seem to encounter this with a variety of ActiveX controls.
Any ideas?
===============================================================
Error info:
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="Interop.SVGACTIVEXLib"
StackTrace:
at SVGACTIVEXLib.ISVGControl.set_SRC(String pVal)
at AxSVGACTIVEXLib.AxSVGCtl.set_SRC(String value)
at SvgDocTest.Form1.LoadFile(String fname) in C:\Documents and Settings\mfdatsw1\My Documents\ADEPT\SPS-49\SVG Viewer Source Code Trials\CodeProject SVG Viewer\SvgDocTest\Form1.cs:line 258
at SvgDocTest.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\mfdatsw1\My Documents\ADEPT\SPS-49\SVG Viewer Source Code Trials\CodeProject SVG Viewer\SvgDocTest\Form1.cs:line 238
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at SvgDocTest.Form1.Main() in C:\Documents and Settings\mfdatsw1\My Documents\ADEPT\SPS-49\SVG Viewer Source Code Trials\CodeProject SVG Viewer\SvgDocTest\Form1.cs:line 218
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
|
|
|
|
|
My requirement is copy the binary data (Images) in base64 form ( from one file, say File B) and paste it to another file say File A.
Here is my FileA looks like ..
<BaseNode >
<rect x="352" y="201.715" fill="none" width="101.429" height="12.143"/>
<text id="XMLID_7_" X="352" Y="210" font-family="'MyriadPro-Regular'" font-size="12">Value1</text>
<image overflow="visible" width="144" height="44" id="XMLID_10_" xlink:href="data:image/jpeg;base64, /9j//...
</image>
<image overflow="visible" width="144" height="44" id="XMLID_11_" xlink:href="data:image/jpeg;base64, /9j//...
</image>
<image overflow="visible" width="144" height="44" id="XMLID_12_" xlink:href="data:image/jpeg;base64, /9j//...
</image>
</BaseNode>
I am picking the image data from File B and pasting it to File A( given above)
So I have written the code like.
string
valueImagePortrait = fileB.SelectSingleNode("//CustomerData//BinaryData//PortraitFile").InnerText;
string valueImageSign = fileB.SelectSingleNode("//CustomerData//BinaryData//SignatureFile ").InnerText;
string valueImageBG = fileB.SelectSingleNode("//CustomerData//BinaryData//BGFile ").InnerText;
XmlNodeList nodeToChangeImage = fileA.GetElementsByTagName(
"image");
for (int i = 0; i < nodeToChangeImage.Count; i++){
XmlAttributeCollection curAttributes1 = nodeToChangeImage[0].Attributes;
curAttributes1.GetNamedItem["xlink:href"].InnerText = "data:image/jpeg;base64,"+ valueImageBG;
XmlAttributeCollection curAttributes2 = nodeToChangeImage[1].Attributes;
curAttributes2["xlink:href"].InnerText = "data:image/jpeg;base64,"+valueImagePortrait;
XmlAttributeCollection curAttributes3 = nodeToChangeImage[2].Attributes;
curAttributes3["xlink:href"].InnerText = "data:image/jpeg;base64,"+ valueImageSign;
}
This is not a perfect code. I am very new to adapt all the XML Apis. Actually this code works fine.
If there are fixed three nos. of <image> nodes in the file A.
But these node are quite, they can be two, one , or more <image> node in file A.
In that situation program crashes.
Can you please help me to provide the optimized sample code to deal with this, using C# for this.
Thanks
|
|
|
|
|
I just want read the value of x and y from the <<rect>>
and remove the transform attribute from <<text>>
and place the earlier read xand y as a x and y atribute to <<text>>
can some body help me out with a sample code for that.
below is a sample format which i have to modify.
OR read the last two value from the transform attribute ::transform="matrix(1 0 0 1 100.1431 112.2344)"
and delete the transform attribute and add the two bold values and x and y attributes.
<<rect x="100.143" y="103.714" style="fill:none;" width="87.857" height="12.143"/>>;
<text transform="matrix(1 0 0 1 100.1431 112.2344)" style="font-family:'MyriadPro-Regular'; font-size:12;">Name;/text>>;
|
|
|
|
|
I am using the SVG-library with success. But when the graphics become more complex*) the server hangs and the debugger says "stack overflow error" in function GetXML().
When switching off parts of the drawing, the library works.
Does anyone know how this error can be corrected?
Thank You, Franz
*) The drawing consists of up to 6 charts with about 100 vertical lines. The amount of lines is the problem. When the lines are omited, the drawing works and also when then amount of charts per drawing is reduced to 4.
|
|
|
|
|
Hello, i'm trying to make this work, so i wrote:
SvgNet.SvgGdi.SvgGraphics g= new SvgNet.SvgGdi.SvgGraphics();
g.FillEllipse(brush, new Rectangle(0, 0, 50, 50));
Pen pen = new Pen(Color.Gray, 10);
g.DrawEllipse(pen, 5, 5, _imageSize.Width - 10, _imageSize.Height - 10);
StreamWriter sw = new StreamWriter("file.svg");
sw.Write( g.WriteSVGString() );
well the output is'nt rendered by firefoxf or any other svg viewer, any idea how to make compatible output?
br mode="hold" />
]>
<svg id="SvgGdi_output">
<rect x="0" y="0" width="100%" height="100%" style="fill:rgb(240,240,240);" id="background">
<g style="&E1;" id="root_group">
<ellipse ry="50" rx="50" style="&E2;" cy="50" cx="50" id="10">
<ellipse ry="45" rx="45" style="&E3;" cy="50" cx="50" id="11">
<defs id="clips_hatches_and_gradients">
|
|
|
|
|
Hi again.
I'm trying to know how to read SVG files with this library, but please, anybody can post an example to read SVG file?
example:
SvgElement ele = new SvgElement();
ele.read("path to svg file");
ele.show();
Anybody can teach me how to do it (read svg files and show them)?
Thanks.
|
|
|
|
|
You cant read the .SVG file using this library. That portion is not written in this library.
If you really want to do that you have to write you own piece of code. To read the code to reading the .SVG.
I read to do it I was able to do but struck while reading the matrix transformation.
If you would able to write it or get the help somewhere , please le me knw too.
Thanks,
|
|
|
|
|
|
Hi Nikkie.
I wrote my own code to read the svg file.
I used an algorithm to read a simple xml file, you can see it here http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx[^]
in the sample number 2 you will see how it works with xmlelements. I use a GoDiagram library to draw the differents figures, for example, if xmlelement == "line" so draw.line(coorx, coory), the coordinates in svg document are the attributes, so you can read the coordinates too.
So you can read the svg file and you can draw the same figure with c#. You can draw without GoDiagram too, only you need to know how to draw lines, circles or wathever in c#.
Have a nice day.
Marcosjgr.
|
|
|
|
|
HOw you are dealing with the transform matrix,
I am struck with that portion can you help.
How you are reading the 6 cordinates of the attribute transform=matrix(1,2,3,4,5,6)
|
|
|
|
|
Hi everybody.
I have Vista SP1 and VS 2008 in my pc. Of course, now I downloaded SVG Adobe too and SVG version 0.92.
I'm trying to compile this project but some errors occurs.
My firts question is about the windows, maybe this project does not run here and maybe does not run with VS 2008 too. So if it runs please tell me what I need to do.
Second.
About the errors:
First I Build the solution in VS2008 no errors happends but 708 warnings appears, here is one:
Warning 1 Missing XML comment for publicly visible type or member 'SvgNet.SvgElement._children' C:\Users\M\Documents\Proyectos\svgnet_src092\SvgNet\SvgNet\SvgElement.cs 59 23 SvgNet
Second. I select SvgDocTest as startup project so when I run the project a exceptions happends:
((System.ComponentModel.ISupportInitialize)(this.svgOut)).EndInit()
Here is the part of the code that the project stop, and the exception:
COMException was unhandled
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
If anybody know how to resolved, please post it .
Thanks .
Marcos G.
|
|
|
|
|
I reply myself.
Well for all folks that use Vista, take care, because the adobe plug in does not working fine in this O.S.<br />
Use XP to compile this project.
|
|
|
|
|
Hi all, how can I use the SvgAElement adding a link to an element?
|
|
|
|
|
At first be sure that you are using 092 version of SVGNet, and after here is an example:
SvgAElement link = new SvgAElement("BrifCahiers.aspx");
link.Href = "xlink:href=\"BrifCahiers.aspx\" ";
SvgTextElement text = new SvgTextElement("Textastic!", 3, 400);
link.AddChild(text);
root.AddChild(link);
"BrifCahiers.aspx" is the target file for the link
|
|
|
|
|
Hello every body,
Actually I'm trying to run a simple example from SvgDocTest.
But nothing is displayed at running the page.
Here is the code:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// SvgElement myRootElement = new SvgElement();
//
// SvgLineElement myLine = new SvgLineElement(50, 130, 850, 130);
// SvgTextElement myTitle = new SvgTextElement("Enculé", 50, 120);
// myRootElement.AddChild(myLine);
// myRootElement.AddChild(myTitle);
SvgSvgElement root = new SvgSvgElement("4in", "4in", "0,0 100,100");
//adding multiple children
root.AddChild(
new SvgRectElement(5, 5, 5, 5)/*,
new SvgEllipseElement(30, 10, 8, 12),
new SvgTextElement("Textastic!", 3, 20)*/
);
}
}
Any help will be apreciated
Thanks
Ali
|
|
|
|
|
Should add these lines in order to work.
string s = root.WriteSVGString(true,true);
Response.ContentType = "image/svg+xml";
Response.Write(s);
|
|
|
|
|