【问题标题】:Set print orientation to landscape with a c# Winforms WebBrowser Control使用 c# Winforms WebBrowser 控件将打印方向设置为横向
【发布时间】:2009-11-20 03:52:44
【问题描述】:

我需要在 winforms 应用程序中以编程方式更改我的一个 webbrowser 控件的打印方向。从我在其他帖子中读到的内容...看起来唯一的方法是通过编程注册表编辑、打印,然后将注册表更改回来。

这是唯一的解决方案吗?如果是这样,任何人都可以帮助以正确的方式在代码中执行此操作吗?

【问题讨论】:

    标签: c# winforms printing


    【解决方案1】:

    我想...这是它在 WPF 中的完成方式:

    var dialog = new PrintDialog(); 
    
    if (dialog.ShowDialog() == true) 
    {
         System.Printing.PrintTicket pt = dialog.PrintTicket;
         pt.PageOrientation = System.Printing.PageOrientation.Landscape;
    
         dialog.PrintTicket = pt;
    
         // Print the element. 
         dialog.PrintVisual(ReportContentPresenter, "Report"); 
    } 
    

    这里奇怪的是,即使在添加对此 DLL 的引用之后,您也不会在 System.Printing 中找到 PrintTicket。您还必须添加对 ReachFramework 的引用才能在 intelisense 中获取 PrintTicket。Microsoft 从未停止用简单的事物来创造谜团......!!享受吧!

    【讨论】:

      【解决方案2】:

      您是否尝试过: printDialog.Document.DefaultPageSettings.Landscape = true;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-10-08
        • 2010-11-12
        • 1970-01-01
        • 1970-01-01
        • 2017-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多