【问题标题】:WPF: How do you print in Landscape mode?WPF:如何在横向模式下打印?
【发布时间】:2011-07-15 02:54:58
【问题描述】:

在网上找到了this function,效果很好……除了我不知道如何将其默认为横向打印。

private void PrintClick(object sender, RoutedEventArgs e)
{
  PrintDialog dialog = new PrintDialog();
  if (dialog.ShowDialog() == true)
  { dialog.PrintVisual(_PrintCanvas, "My Canvas"); }
}

如何将我的 wpf 内容的默认设置设置为横向模式?

【问题讨论】:

    标签: wpf printing landscape


    【解决方案1】:

    编辑:固定变量名,@SHIN JaeGuk 提到

    private void PrintClick(object sender, RoutedEventArgs e)
    {
        PrintDialog dialog = new PrintDialog();
        if (dialog.ShowDialog() == true)
        { 
            //Set PageOrientation to Landscape
            dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            dialog.PrintVisual(_PrintCanvas, "My Canvas"); 
        }
    }
    

    【讨论】:

      【解决方案2】:

      原始答案 这已经回答了: Setting PageOrientation for the Wpf DocumentViewer PrintDialog

      结束原始答案

      编辑:

      PrintTicket 和打印视觉效果似乎存在问题,请查看: Same question on MSDN

      MSDN 论坛上的原始发帖人在上一篇文章中说他们使用的解决方法是基本上捕获视觉并转换为 xps 文档进行打印,这将允许使用 PrintTicket 设置打印文档的方向.

      【讨论】:

      • 我看的不是打印文档,而是打印一段内容。例如,现在我将(Visual)mytabs.SelectedContent 传递到我的print.printVisual() 方法中。在您指出的答案中,我究竟会将我的mytabs.SelectedContent 贴在哪里?
      【解决方案3】:
      private void PrintClick(object sender, RoutedEventArgs e)
      {
         PrintDialog dialog = new PrintDialog();
         if (dialog.ShowDialog() == true)
            { 
               dialog.PrintTicket.PageOrientation=System.Printing.PageOrientation.Landscape;
               dialog.PrintVisual(this, "First LandScape"); 
            }
       }
      

      您需要分别添加对 ReachFramework.dll 和 System.Printing.dll 的引用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-23
        • 1970-01-01
        相关资源
        最近更新 更多