[英]Using a C# WebBrowser control, can I print the document with different headers on each page?
first, when I say header, i dont mean the text in the tags... I mean like the header of the page when printing.首先,当我说 header 时,我不是指标签中的文字......我的意思是像打印时页面的 header。
So basically what I need is to be able to change the header of certain pages based on what "section" the current page is describing...So it might look something like this所以基本上我需要的是能够根据当前页面描述的“部分”来更改某些页面的 header ......所以它可能看起来像这样
**Header for Section 11-33-00**
Section 11-33-00 Text
...
...
<new page>
**header for section 11-33-00**
Section 11-33-00 More text
..
..
<new page>
**header for section 28-30-00
Section 28-30-00 text
..
..
As you can see from the example, Pages 1 and 2 both have information for section 11-33-00, so they have the same header.从示例中可以看出,第 1 页和第 2 页都有第 11-33-00 节的信息,因此它们具有相同的 header。 Then on page 3, the header changes.
然后在第 3 页,header 发生变化。
The default headers when printing have "Page 1 of 3"...this value changes as the pages change, so how does this happen?打印时的默认标题有“第 1 页,共 3 页”……这个值会随着页面的变化而变化,那么这是怎么发生的呢? Is there a way for me to have an array of the different section that the printPreviewDialog will look at, and change the value of the header depending on the current page?
有没有办法让我拥有 printPreviewDialog 将查看的不同部分的数组,并根据当前页面更改 header 的值?
for example, instead of these headers:
Page 1 of 3
Page 2 of 3
Page 3 of 3
I would have:
Section 11-22-33
Section 11-22-33
Section 22-33-99
? ?
Or is this completely impossible......或者这完全不可能……
If you have any ideas I would appreciate, cause right now all I can do is hide the headers using this code:如果您有任何想法,我将不胜感激,因为现在我所能做的就是使用以下代码隐藏标题:
string keyName = @"Software\Microsoft\Internet Explorer\PageSetup";
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true)) {
if (key != null) {
string[] str = new string[] {"One", "Two"};
key.SetValue("footer", str);
key.SetValue("header", "");
web_display.ShowPrintPreviewDialog();
}
}
Thanks!!谢谢!!
To get print preview from webbrowser control use要从 webbrowser 控件获取打印预览,请使用
webBrowser1.ShowPrintPreviewDialog();
you can get a very good article in code project link http://www.codeproject.com/KB/cs/WBrowser.aspx您可以在代码项目链接http://www.codeproject.com/KB/cs/WBrowser.aspx中获得非常好的文章
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.