web浏览器打印设置 [英] WebBrowser print settings

查看:1079
本文介绍了web浏览器打印设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我ca的如何改变我的html文件的方向(为横向)使用WebBrowser控件进行打印。

How ca i change my html document orientation(to Landscape) for printing using WebBrowser control.

var browser = new WebBrowser();
browser.DocumentCompleted += (sender, args) =>
    {
        var ws = sender as WebBrowser;
        //change paper size and orientation
        ws.Print();
    };
browser.Navigate(path);

我需要改变纸张大小格式C5和方向设置为横向打印前。 我怎样才能做到这一点没有任何对话?

I need to change paper size format to C5 and orientation to Landscape before printing. How can i do this without any dialogs?

推荐答案

要控制之外的 @媒体CSS web浏览器(包括WinForms和WPF),您将需要实现自己的 Internet Explorer的打印模板。这将提供完全控制标题,边距,列等。

To control HTML printing layout beyond @media CSS with WebBrowser (both WinForms and WPF), you would need to implement your own Internet Explorer Print Template. That would provide full control over headers, margins, columns, etc.

具体而言,您以后 TemplatePrinter是。定向。这是不正确的记载,但它的工作原理。标准的IE打印模板的源代码可以在导航到水库查看://ieframe.dll/$p$pview.dlg

Specifically, you're after TemplatePrinter.orientation. It isn't properly documented, but it works. The source of the standard IE print template can be viewed when navigated to res://ieframe.dll/preview.dlg.

其他的一些相​​关的资源:

Some other relevant resources:

  • Beyond Print Preview: Print Customization for Internet Explorer 5.5
  • Print Preview 2: The Continuing Adventures of Internet Explorer 5.5 Print Customization
  • Print Templates, Part I
  • View templates for HTML source documents
  • Demystifying printing with the Microsoft WebBrowser control and ShowHTMLDialogEx
  • Add support to print & preview HTML in a dialog-based MFC app
  • IDM_PRINT
  • IDM_PRINTPREVIEW
  • MSKB: How to print custom headers and footers for a WebBrowser control in Internet Explorer

这篇关于web浏览器打印设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆