title: Printing Canvas using PrintDialog in WPF
body: <p>I am trying to take the print of Canvas in A4 size by setting height and width to  29.7cm and 21cm respectively.</p>
  
  <p>I am getting proper output on Windows 7 devices. But for Windows 10 devices, the print output is not same as Windows 7 devices.</p>
  
  <p>The real problem is height and width is not maintained for Windows 10 devices.</p>
  
  <p>Please Help and Suggest Me !!</p>
  
  <p><strong>Please find below code:</strong></p>
  
  <p><strong>Xaml:</strong></p>
  
  <pre><code>&lt;Window x:Class="TestSolution.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          VerticalContentAlignment="Stretch"
          HorizontalContentAlignment="Stretch"
          Height="29.7cm"
          Width="21cm"
          ResizeMode="NoResize"&gt;
      &lt;Grid x:Name="grdTest" 
             VerticalAlignment="Stretch"
                  HorizontalAlignment="Stretch"
             Height="29.7cm"
                  Width="21cm"&gt;
           &lt;Canvas x:Name="cnvTest"
                  VerticalAlignment="Stretch"
                  Height="29.7cm"
                  Width="21cm"
                  HorizontalAlignment="Stretch"&gt;
          &lt;/Canvas&gt;               
      &lt;/Grid&gt;         
  &lt;/window&gt;
  </code></pre>
  
  <p><strong>Code Behind</strong></p>
  
  <pre><code>private void btn_Click(object sender, RoutedEventArgs e)
          {
              PrintDialog prnt = new PrintDialog();
  
              if (prnt.ShowDialog() == true)
              {
                  prnt.PrintVisual(cnvTest, "Printing Canvas");
              }
              this.Close();
          }
  </code></pre>