title: Real size WPF controls for printing
body: <p>I am currently developing an application where users can create/move TextBlocks on a canvas dynamically. Once they have positioned the TextBlocks where they want them they can press a print button which will cause a ZPL printer to print what is currently displayed on screen.</p>
  
  <p>The ZPL commands are built by taking the following values from each TextBlock:</p>
  
  <ul>
  <li>XPosition = Canvas.Left</li>
  <li>YPosition = Canvas.Right</li>
  <li>Text = Text</li>
  </ul>
  
  <p>However I can't find a way of getting the printout to resemble the on screen display. I guess this is because the values of Canvas.Left and Canvas.Right do not match up with the printers DPI. </p>
  
  <p>Here is the conversion I am currently using (because I thought the Canvas.Left = 1 means 1/96th of an inch) (Top left of the canvas is 0,0)</p>
  
  <pre><code>public double GetZplXPosition(UIElement uiElement)
  {
      int dpiOfPrinter = 300;
      double zplXPosition = (Canvas.GetLeft(uiElement) / 96.0) * dpiOfPrinter;
      return zplXPosition;
  }
  </code></pre>
  
  <p>Is there I can display controls in "real size". The paper being used will always be A5 (8.3 in x 5.8 in).</p>
  
  <p>I thought about using a viewbox around a Canvas which had its width and height set to 830 x 580 (ratio correct for A5) however this didn't help.</p>
  
  <p>Any suggestions??</p>
  
  <p>Thanks</p>