Transforming an InfoPath Ink Picture into WordML

On a current project I was tasked with using XSLT to transform InfoPath form files into Word 2003 documents. The InfoPath form template used to create the XML input was designed for a tablet PC and thus had an ink picture control, the data for which needed to appear in the corresponding Word document. To complicate matters, the ink picture in the form template used a background image, which also needed to be output in Word.

Getting the ink picture data transformed into Word is not too difficult. The user’s drawing actions are stored as base64Binary within the element in your form’s data source that is bound to the ink picture control. If you add an <xsl:value-of select=”Ink-Picture-Element-Name“/> to your .xsl file, the base64Binary data can be output in a w:binData element within a w:pict element in your WordML file.

Getting the background image for the ink picture to appear correctly in Word is a little more involved. That image is not stored in the InfoPath form’s data source, so it needs to be included directly in the .xsl file. Additionally, within your .xsl file you will need to set the image’s wrapping style to “behind text”, allowing the ink picture data to overlay the background image. The “behind text” option is achieved by setting the corresponding v:shape element’s z-index property to -1, as shown in the following example:

<v:shape id="_x0000_s1026"
    type="#_x0000_t75"
    alt="Ink Picture"
    style="position:absolute;margin-left:0;margin-top:0;width:172.5pt;height:172.5pt;z-index:-1;mso-position-horizontal:left;mso-position-horizontal-relative:text;mso-position-vertical-relative:text">

For those not interested in editing the WordML directly, there is also the option of setting the background image properties in Word, saving the results as XML, and then copying the WordML markup into your .xsl file. To set the “behind text” option in Word:

  1. Double-click the picture object.
  2. In the Format Picture dialog box, click the Layout tab.
  3. In the Wrapping style section, click Behind text and click OK.

In order to ensure that the ink picture data would align properly with the background image, both w:pict elements were given the same dimensions and placed inside a table cell that had a fixed height and width.

Leave a Reply

Your email address will not be published. Required fields are marked *