You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Laurent FALLET <la...@insa-rouen.fr> on 2004/03/27 17:31:39 UTC
Drawing a text in a SVG document
Hello,
I'm starting with Batik, and I'm trying to do a servlet sending a svg
document to a client. I want to put a text in this SVG. I tried with a
graphics2D, but without success... the SVG document seems to be empty.
Is there a simple way to draw text?
Could anyone give a little piece of code?
Thanks,
Laurent
--
Laurent FALLET - laurent.fallet@insa-rouen.fr
Elève-ingénieur à l'INSA de Rouen - http://asi.insa-rouen.fr/~lfallet/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Tonny Kohar <to...@kiyut.com>.
Hi,
> Here is the point : is there something like TextElement texte1 = new
> TextElement("name",x,y,"Arial",12pt,...) ?
As far as I know there is no such thing in SVG DOM. However for text
styling you can use style attribute and append those text param in one
go. But not for x & y attribute.
Regards
Tonny Kohar
--
Sketsa
SVG Graphics Editor
http://www.kiyut.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Tonny Kohar <to...@kiyut.com>.
Hi,
> <text xml:space="preserve" x="10" y="40" style="stroke:none;">Value from
> the html form</text>
>
> - using the DOM implementation
> Element svgRoot = document.getDocumentElement();
> Element texteElmt = document.createElementNS(svgNS, "text");
texteElmt(null, "x","10");
texteElmt(null, "y","40");
texteElmt(null, "style,"stroke:none;");
Text text = document.createTextNode("Value from html from");
texteElmt.appendChild(text);
svgRoot.appendChild(texteElmt);
Regards
Tonny Kohar
--
Sketsa
SVG Graphics Editor
http://www.kiyut.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Laurent FALLET <la...@insa-rouen.fr>.
Hello,
I'm sorry if you find I'm a pain in the neck... but I would like to
understand. I try to use Batik to create (from values obtained from a html
form) an SGV document. I want to create the element :
<text xml:space="preserve" x="10" y="40" style="stroke:none;">Value from
the html form</text>
Up to now, I found 2 solutions :
- using a graphics2D :
SVGGraphics2D svgGraphics = new SVGGraphics2D(document);
float x=10,y=20;
svgGraphics.drawString("Salut "+nom+" "+prenom+"!",x,y);
...
Then SVGGraphics2D is converted to SVG.
- using the DOM implementation
Element svgRoot = document.getDocumentElement();
Element texteElmt = document.createElementNS(svgNS, "text");
...
Then attributes are added, but by hand...
Here is the point : is there something like TextElement texte1 = new
TextElement("name",x,y,"Arial",12pt,...) ?
That is to say, is there classes that can create an object?
And then, apply object.method like texte1.getBBox()?
Does anyone see what I mean?
Regards,
Laurent
> Laurent FALLET schrieb:
>
>>I'm just short because I don't know well Batik, I've no problem in
>> generating the svg, but in putting elements inside (as a matter of
>> fact, a text element). Is there a tutorial of Batik somewhere? I found
>> this one : http://xml.apache.org/batik/svggen.html but it's abour
>> SVGGraphics2D.
>>
>>
>>
>
> I suspect you're looking more for tutorials on SVG itself rather than
> Batik:
>
> 1.) Check the SVG 1.1 Spec on the text element here:
> http://www.w3.org/TR/SVG11/text.html
>
> 2.) Also, I would look at the right-hand menu of
> http://www.w3.org/Graphics/SVG/.
> In the Articles, Books, and Links sections--you will probably find
> something you can use.
>
> Glen
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
--
Laurent FALLET - laurent.fallet@insa-rouen.fr
Elève-ingénieur à l'INSA de Rouen - http://asi.insa-rouen.fr/~lfallet/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Glen Mazza <gr...@yahoo.com>.
Laurent FALLET schrieb:
>I'm just short because I don't know well Batik, I've no problem in
>generating the svg, but in putting elements inside (as a matter of fact, a
>text element). Is there a tutorial of Batik somewhere? I found this one :
>http://xml.apache.org/batik/svggen.html but it's abour SVGGraphics2D.
>
>
>
I suspect you're looking more for tutorials on SVG itself rather than Batik:
1.) Check the SVG 1.1 Spec on the text element here:
http://www.w3.org/TR/SVG11/text.html
2.) Also, I would look at the right-hand menu of
http://www.w3.org/Graphics/SVG/.
In the Articles, Books, and Links sections--you will probably find
something you can use.
Glen
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Laurent FALLET <la...@insa-rouen.fr>.
> Possible questions to help zero in on the problem:
>
> 1. What is the your client--is it a web browser (which type)?
It's a web browser, either Opera or Mozilla, with the Adobe plug in. I can
see my svg, I can edit the source, everything works well on this side.
> 2. Can your client read the same SVG document if instead of being sent
> by the servlet, the SVG doc is on the local filesystem? (I wonder if the
> problem is with the client not being able to display the svg text
> element, not with the servlet.)
I'm just short because I don't know well Batik, I've no problem in
generating the svg, but in putting elements inside (as a matter of fact, a
text element). Is there a tutorial of Batik somewhere? I found this one :
http://xml.apache.org/batik/svggen.html but it's abour SVGGraphics2D.
> 3. Can you trap (e.g., if the client is a web browser, right-clicking
> and choosing "view source") the document that the servlet is sending and
> see that the text element is indeed within the document. ( Here, I
> want to see if your client is OK but the problem is with your servlet
> code not creating the svg text element.)
>
> Glen
The problem is more that I don't know how to code than in the client nor
in the servlet ;)
Have a nice day,
Laurent
> Laurent FALLET schrieb:
>
>>Yes I've done it (drawing a rectangle), even text but with the method
>> drawString, from a Graphics2D component. I can send graphics2D objects,
>> but is it possible to create a text element, fix attributes, and then
>> put the element into svg document, without using graphics2D?
>>Laurent
>>
>>
>>
>>
>>>Were you able to send non-text items in the SVG Document--e.g., a
>>> simple
>>> rectangle, circle, etc.?
>>>I don't know if your problem is that you just can't send *text*, or if
>>> you can't send anything; the latter may indicate problems not related
>>> to
>>> SVG.
>>>
>>>Glen
>>>
>>>Laurent FALLET schrieb:
>>>
>>>
>>>
>>>>Hello,
>>>>I'm starting with Batik, and I'm trying to do a servlet sending a svg
>>>> document to a client. I want to put a text in this SVG. I tried with
>>>> a graphics2D, but without success... the SVG document seems to be
>>>> empty. Is there a simple way to draw text?
>>>>Could anyone give a little piece of code?
>>>>Thanks,
>>>>Laurent
>>>>
>>>>
>>>>
>>>>
>>>>
>>>---------------------------------------------------------------------
>>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>>
>>>
>>
>>
>>
>>
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
--
Laurent FALLET - laurent.fallet@insa-rouen.fr
Elève-ingénieur à l'INSA de Rouen - http://asi.insa-rouen.fr/~lfallet/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Glen Mazza <gr...@yahoo.com>.
Possible questions to help zero in on the problem:
1. What is the your client--is it a web browser (which type)?
2. Can your client read the same SVG document if instead of being sent
by the servlet, the SVG doc is on the local filesystem? (I wonder if the
problem is with the client not being able to display the svg text
element, not with the servlet.)
3. Can you trap (e.g., if the client is a web browser, right-clicking
and choosing "view source") the document that the servlet is sending and
see that the text element is indeed within the document. ( Here, I want
to see if your client is OK but the problem is with your servlet code
not creating the svg text element.)
Glen
Laurent FALLET schrieb:
>Yes I've done it (drawing a rectangle), even text but with the method
>drawString, from a Graphics2D component. I can send graphics2D objects,
>but is it possible to create a text element, fix attributes, and then put
>the element into svg document, without using graphics2D?
>Laurent
>
>
>
>
>>Were you able to send non-text items in the SVG Document--e.g., a simple
>> rectangle, circle, etc.?
>>I don't know if your problem is that you just can't send *text*, or if
>>you can't send anything; the latter may indicate problems not related to
>> SVG.
>>
>>Glen
>>
>>Laurent FALLET schrieb:
>>
>>
>>
>>>Hello,
>>>I'm starting with Batik, and I'm trying to do a servlet sending a svg
>>>document to a client. I want to put a text in this SVG. I tried with a
>>>graphics2D, but without success... the SVG document seems to be empty.
>>>Is there a simple way to draw text?
>>>Could anyone give a little piece of code?
>>>Thanks,
>>>Laurent
>>>
>>>
>>>
>>>
>>>
>>--------------------------------------------------------------------- To
>>unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Laurent FALLET <la...@insa-rouen.fr>.
Yes I've done it (drawing a rectangle), even text but with the method
drawString, from a Graphics2D component. I can send graphics2D objects,
but is it possible to create a text element, fix attributes, and then put
the element into svg document, without using graphics2D?
Laurent
> Were you able to send non-text items in the SVG Document--e.g., a simple
> rectangle, circle, etc.?
> I don't know if your problem is that you just can't send *text*, or if
> you can't send anything; the latter may indicate problems not related to
> SVG.
>
> Glen
>
> Laurent FALLET schrieb:
>
>>Hello,
>>I'm starting with Batik, and I'm trying to do a servlet sending a svg
>> document to a client. I want to put a text in this SVG. I tried with a
>> graphics2D, but without success... the SVG document seems to be empty.
>> Is there a simple way to draw text?
>>Could anyone give a little piece of code?
>>Thanks,
>>Laurent
>>
>>
>>
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
--
Laurent FALLET - laurent.fallet@insa-rouen.fr
Elève-ingénieur à l'INSA de Rouen - http://asi.insa-rouen.fr/~lfallet/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing a text in a SVG document
Posted by Glen Mazza <gr...@yahoo.com>.
Were you able to send non-text items in the SVG Document--e.g., a simple
rectangle, circle, etc.?
I don't know if your problem is that you just can't send *text*, or if
you can't send anything; the latter may indicate problems not related to
SVG.
Glen
Laurent FALLET schrieb:
>Hello,
>I'm starting with Batik, and I'm trying to do a servlet sending a svg
>document to a client. I want to put a text in this SVG. I tried with a
>graphics2D, but without success... the SVG document seems to be empty.
>Is there a simple way to draw text?
>Could anyone give a little piece of code?
>Thanks,
>Laurent
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org