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

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

问题描述

如何使用 WebBrowser 控件更改我的 html 文档方向(为横向)以进行打印.

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?

推荐答案

控制 HTML 打印布局超出 @media CSSWebBrowser(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.方向.它没有正确记录,但它有效.导航到 res://ieframe.dll/preview.dlg 时可以查看标准 IE 打印模板的来源.

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.

其他一些相关资源:

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

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