使用 C# WebBrowser 控件,我可以在每页上打印具有不同页眉的文档吗?
首先,当我说标题时,我并不是指标签中的文本...... 我的意思是像打印时的页面标题。
所以基本上我需要的是能够根据当前页面描述的“部分”来更改某些页面的标题...所以它可能看起来像这样 正如
**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
..
..
您从示例中看到的,页面 1 和 2 都是有第 11-33-00 节的信息,因此它们具有相同的标头。然后在第 3 页,标题发生变化。
打印时的默认页眉为“第 1 页,共 3 页”……这个值随着页面的变化而变化,那么这是怎么发生的呢?有没有办法让我拥有 printPreviewDialog 将查看的不同部分的数组,并根据当前页面更改标题的值?
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
?
或者这是完全不可能的……
如果您有任何想法,我将不胜感激,因为现在我所能做的就是使用此代码隐藏标题:
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();
}
}
谢谢!!
first, when I say header, i dont mean the text in the tags...
I mean like the header of the page when printing.
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 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. Then on page 3, the header changes.
The default headers when printing have "Page 1 of 3"...this value changes as the pages change, so how does this happen? 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?
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!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要从网络浏览器控件使用打印预览,
您可以在代码项目链接中获得一篇非常好的文章
http://www.codeproject.com/KB/cs/WBrowser.aspx
To get print preview from webbrowser control use
you can get a very good article in code project link
http://www.codeproject.com/KB/cs/WBrowser.aspx