xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Subhrajyoti Moitra" <smoi...@sapient.com>
Subject How to replace text content in SVG image?
Date Mon, 05 Dec 2005 11:26:29 GMT

Hi People,

I have a problem in replacing text content in a SVG image.

I have text content in the image. I want to replace these texts
dynamically, during runtime.
So suppose I have the following text,  in the template image

<text x="73" y="153" id="samp1_textid1"
transform="matrix(4.69488,0,1.6271e-006,4.98689,-133.402,-685.949)">
	Template text to be replaced by the user.
</text>

The user enters some text from a web form that should appear instead of
the standard text in the image. Then he generates a PNG/TIFF image out
of the final modified (containing his values) SVG image.

So far what I did was used simple DOM API to find out all <text> tags
and then get the next child and do a node replace of that text node with
that of the user values, all using DOM API.
For simple text content like the one above, this approach is working,
but imagine a content like the one below, 


<text id="XMLID_4_" transform="matrix(2.0887 0 0 1 430.5 204.6079)">
	<tspan x="0" y="0" fill="#4D1083"
font-family="'BookAntiqua-Bold'" font-size="76.4411">G</tspan>
	<tspan x="0" y="91.941" fill="#4D1083"
font-family="'BookAntiqua-Bold'" font-size="76.4411">R</tspan>
	<tspan x="0" y="183.882" fill="#4D1083"
font-family="'BookAntiqua-Bold'" font-size="76.4411">A</tspan>
	<tspan x="0" y="275.823" fill="#4D1083"
font-family="'BookAntiqua-Bold'" font-size="76.4411">D</tspan>
	<tspan x="0" y="367.764" fill="#4D1083"
font-family="'BookAntiqua-Bold'" font-size="76.4411"> !</tspan>
</text>

For this my algo above wont work. How do I go about solving the problem.
On top of this, in Illustrator images I also saw the following for which
my algo wont work.

<switch i:objectNS="&ns_flows;" i:objectType="pointText">

<foreignObject requiredExtensions="&ns_flows;" x="0" y="0" width="1"
height="1" overflow="visible">
	<flowDef  xmlns="&ns_flows;"> 
	<region>

		<path d="M197.5,159.394"/>

	</region>

	<flow  xmlns="&ns_flows;"  fill="#F9DB7F" stroke="#BF360C"
font-family="'Georgia-Bold'" font-size="46.0015"
a:adobe-horizontal-scale="0.7833">
		<p><span>Joun Us</span></p> 
		<p><span>Party on 31st Dec</span></p> 
	</flow>
	</flowDef>

<x:targetRef  xlink:href="#XMLID_10_" /> 
</foreignObject>

<text id="XMLID_10_" transform="matrix(0.7833 0 0 1 197.4995 159.3936)">
	<tspan x="0" y="0" fill="#F9DB7F" stroke="#BF360C"
font-family="'Georgia-Bold'" font-size="46.0015">Joun Us</tspan>
	<tspan x="0" y="55.001" fill="#F9DB7F" stroke="#BF360C"
font-family="'Georgia-Bold'" font-size="46.0015">Party on 31st
Dec</tspan>
</text> 							
</switch>

Notice that the above not only uses the span in the text element, it is
actually referred to by the foreignObject thingy.

My intention is to replace all the text in the image with the user
values, retaining the flow path or the orientation of the text.

Please advice.

Thanks a lot in advance,
Subhro.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message