http://onionworks.net/2006/imageservice/canvas

drawText (canvas : nodeset, text : string, positionOrRectangle : nodeset, font : nodeset, fill : nodeset, [textFormat : nodeset]) : nodeset

The method makes it possible to insert text into a picture. The parameters “canvas”, “text”, “positionOrRectangle”, “font”, “fill” and, as an option, “TextFormat”, are to be transferred to the method.

The canvas on which drawing is to take place is to be indicated to "canvas".

The text to be output is to be indicated to "text".

A point or a rectangle can be transferred to "positionOrRectangle". These can be created with the methods “createPoint” or “createRectangle” of the imageservice core functions. If a rectangle is specified, then the text is reduced to this area and excess length cut off if necessary.

The character font of the text is to be indicated to "font". The character font can be created with the methods “createFont” or “loadFont” of the imageservice core functions.

The full colour of the character font is to be specified to "fill". The full colour can be created with the method “createSolidFill” of the imageservice core functions.

"textFormat" can be specified as an option. The TextFormat can be specified with the method “createTextFormat” of the imageservice core functions. If the TextFormat is not specified, then the “createTextFormat” method is called with the values “Left” for “alignment”, “0” for “angle” and “1” for “interCharacterSpace”.

The following example shows the output of the white text "sample text" in the bold character font Arial.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ise="http://onionworks.net/2006/imageservice/encoders" xmlns:iscan="http://onionworks.net/2006/imageservice/canvas" xmlns:is="http://onionworks.net/2006/imageservice" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:template match="/recordcard">
<xsl:variable name="workspace" select="is:createWorkspace(picture, true())" />
<xsl:variable name="drawText" select="iscan:drawText(iscan:createCanvas($workspace),'Beispieltext', is:createPoint(0,0),is:createFont('Arial',10,'Bold'), is:createSolidFill(255,255,255,255),is:createTextFormat('Left',10,0))" />
<xsl:variable name="doWrite" select="is:writeWorkspace($workspace, ise:createJpegEncoder(80))" />
<b:output mimeType="{picture/@onion:mimeType}">
<b:webResponse expires="60" />
</b:output>
</xsl:template>
</xsl:stylesheet>
“drawText” use example

In this example, the white text "sample text" is written into an existing picture. The text is rotated by 10 degrees, has a left alignment and a character spacing of 1. The character font of the text was selected to Arial with character size 10 and the font style “bold”.

The method »drawText()« also returns a nodeset containing information about the text size. This can be accessed in order for example to adapt the area to the text length in graphic navigation. The following source code exemplifies the content of the variable »drawText()« from the above example.

<size width="66" height="17" />
Example of a return value of the method »drawText()«