title: ZPL: How to horizontally centered a line of text on a label regardless of text length
body: <p>I need to center some text horizontally on a label so that if the length of text
  changes it will still remain centered.</p>
  
  <p>I am using XSLT to process the format like this:</p>
  
  <pre><code>        &lt;!-- Position from Home (3.75",4.00")--&gt;
          &lt;xsl:text&gt;&lt;![CDATA[^FT494,812]]&gt;&lt;/xsl:text&gt;
  
          &lt;xsl:text&gt;&lt;![CDATA[^A0B,62,62]]&gt;&lt;/xsl:text&gt;
  
        &lt;!-- I am using the FB command to center the text --&gt;
         &lt;xsl:text&gt;&lt;![CDATA[^FB500,1,0,C]]&gt;&lt;/xsl:text&gt;
  
          &lt;!-- Field Block --&gt;
          &lt;xsl:text&gt;&lt;![CDATA[^FD]]&gt;&lt;/xsl:text&gt;
          &lt;xsl:value-of select="/lb:label/lb:MyDataField" /&gt;
          &lt;xsl:text&gt;&lt;![CDATA[^FS]]&gt;&lt;/xsl:text&gt;
  </code></pre>
  
  <p>So that the output looks like this:</p>
  
  <p>Example A:</p>
  
  <pre><code>        123 Good Street
  1234567890 1234567890 1234567890
  </code></pre>
  
  <p>or</p>
  
  <p>Example: B</p>
  
  <pre><code> 123 Good Street
     1234567890
  </code></pre>
  
  <p>So far the text is not centering and the result looks like this:</p>
  
  <pre><code>        123 Good Street
          1234567890 1234567890 1234567890
  </code></pre>