title: Preserving whitespace in PDF after XSL transform
body: <p>I'm converting an XML to PDF using XSL transformation.  Unfortunately, it is not preserving the whitespace from the XML.  For example:</p>
  
  <p>I want to convert this:</p>
  
  <pre><code>Test Line Data         : 0xAA
  </code></pre>
  
  <p>to PDF from an XML.  It looks fine in the XML, it has the 9 spaces between Data and : but in the PDF it shows</p>
  
  <pre><code>Test Line Data : 0xAA
  </code></pre>
  
  <p>Here is what I currently do.  After writing the data to the XML, I will perform the following:</p>
  
  <pre><code>XPathDocument xPathDocDiag = new XPathDocument(this.FileNameDiagXml);
  XslCompiledTransform xslTransDiag = new XslCompiledTransform();
  XmlTextWriter xmlWriterDiag = new XmlTextWriter(outputFO, System.Text.Encoding.UTF8);
  xslTransDiag.Transform(xPathDocDiag, null, xmlWriterDiag);
  xmlWriterDiag.Flush();
  xmlWriterDiag.Close();
  </code></pre>
  
  <p>And then launch Apache FOP to convert the FO to PDF.  Like I said, unfortunately, the white space is not preserved when I need it to be.  I have tried manually adding &#160; in place of spaces in the XML (find and replace) which does work after the conversion, but as we all know, the literal &amp; can't be in XML so that option is out.  I have tried using XmlReader and then using </p>
  
  <pre><code>&lt;xsl:preserve-space elements="*"/&gt;
  </code></pre>
  
  <p>but again, that doesn't work either (no error or anything, just doesn't work).<br>
  The section of XSL looks like so:</p>
  
  <pre><code>&lt;xsl:when test="Data != ''"&gt;
                  &lt;fo:table-cell text-align="left"&gt;
                      &lt;fo:block /&gt;
                  &lt;/fo:table-cell&gt;
                  &lt;fo:table-cell text-align="left" number-columns-spanned="7"&gt;
                      &lt;fo:block font-family="Courier New, Courier, monospace" font-size="9pt"&gt;&lt;xsl:value-of select="Data" /&gt;&lt;/fo:block&gt;
                  &lt;/fo:table-cell&gt;
              &lt;/xsl:when&gt;
  </code></pre>
  
  <p>I have tried all sorts of attribute modifying to no avail.  Am I missing something obvious here?  </p>