Search code examples
xmlxslt-2.0xsl-fo

xsl:fo How to draw checkboxes


guys I need a checkboxes in my xsl:fo document and so the question, is their a way in fo ,or need I an picture(graphic) ?

I use FOP and xslt 2.0

Here is a picture of the checkbox enter image description here


Solution

  • Using a font that contains a checkbox image is one way (Wingdings has a few checkboxes). But you can also place SVG code in your FO template.

    Example for a 5x5 mm rectangle (off the top of my head, needs checking):

    <fo:block>
        <fo:instream-foreign-object>
            <svg width="5" height="5">
                <rect width="5" height="5" style="stroke-width:0.5;stroke:rgb(0,0,0)" />
            </svg> 
        </fo:instream-foreign-object>
    </fo:block>
    

    And you need to declare the svg namespace in your FO template: xmlns="http://www.w3.org/2000/svg"