By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

[xsl] representing checkboxes (with images)

P: 2
This is doing my head in...

We're starting to migrate our report-printing and such (forms included) to pdf - using xml files and nFOP with In this case I have to print out a form which contains a whole lot of checkboxes, so I made 2 gifs of 12x12 pixels that represent the empty and checked states. Because I use so many checkboxes, I thought about making a template with a parameter wether it should be checked or not (if the xml contains any data, otherwise everything will be blank - we have to offer both possibilities). Here's what the template looks like (I had content-width and content-height, and width and height set at some point. All the same apparently)

Expand|Select|Wrap|Line Numbers
  1. <xsl:template name="checkbox">
  2.   <xsl:param name="checked" />
  3.     <xsl:choose>
  4.       <xsl:when test="$checked='false'">
  5.         <fo:external-graphic  src="url('')"/>
  6.       </xsl:when>
  7.       <xsl:when test="$checked='true'">
  8.     <fo:external-graphic src="url('')" />
  9.       </xsl:when>
  10.     </xsl:choose>
  11. </xsl:template>
and in my code for the moment - since i dont have access to the db the form will take its data from right now - I have this to call the template:
Expand|Select|Wrap|Line Numbers
  1. <fo:table-cell padding-top="2px">                                  
  2.   <fo:block>
  3.     <xsl:call-template name="checkbox">                                      
  4.       <xsl:with-param name="checked" select="'false'" />                    
  5.     </xsl:call-template>
  6.   </fo:block>
  7. </fo:table-cell>
and I change false for true if I want it checked.

As long as its inline, the result is alright. The checkboxes will display a tad under the text level (due to the disposition of form - originally made in word - I can't use tables and put the image in a block, it would just make the structure complicated, hard to maintain, and in the end it probably would turn out just as ugly) but i can deal with that. However, if I try to shoot the textbox in a table-cell (inside of a block - like my previous code snippet) and alone, all hell breaks loose and the images display where they shouldn't be. Here's a picture to show you the problem (I added a border to the cell where the top left square is, or should be)

I would've wanted to do that and I don't think I would've managed! The checkboxes should be displaying level with the line on the left as they are in the same table-row... so why are they sticking on the top-left corner?

I have tried so many things, from a <fo:inline-container> with all sorts of positioning (alignment-adjust, alignment-baseline... etc) to putting the image inside of a floating block... I'm not quite sure what all I am supposed to do - or try - anymore. I also tried the image alone without the template: same results. the only change i can create is by adding a padding-top to the block that containts said checkbox (equal to its height) I can make it go down to its normal level. It's still way offset to the left and padding-left won't change a thing. Margin-left on the block somehow stretches the image, so im leaving that one out (and even with width and height specified). Has anyone ever come across something like this? Or does anyone have a different idea on how I would render these? Nothing seems to work. :(:confused:

Thank you in advance for your time
Oct 18 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.