简体   繁体   English

使用 C# WebBrowser 控件,我可以在每页上打印具有不同标题的文档吗?

[英]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.

相关问题 如何使用Acobat Reader在C#中打印pdf文档的第一页? - How can i print first page of a pdf document in C# using Acobat Reader? C#使用隐藏的Web浏览器控件获取页面内容 - C# using hidden webbrowser control to get content of page C# - 使用webbrowser控件将字符串传递到网页中的文本框 - C# - Pass string to textbox in web page using the webbrowser control C#我可以在Web浏览器控件中自动化下拉框吗? - C# Can I Automate Drop Down Box in webbrowser control? C#.NET如何在WebBrowser控件上显示图像? - C# .NET How can I show an image on WebBrowser control? C#我可以刮一个webBrowser控件来获取链接吗? - C# can I Scrape a webBrowser control for links? 为什么我不能使用C#WebBrowser控件触发选择更改事件? - Why can't I trigger select change event using C# WebBrowser control? 如何打印WebBrowser控件的内容? - How can I print the contents of a WebBrowser control? 在C#中的WebBrowser控件中获取适用于平面媒体CSS样式的网页 - Getting Print media CSS style applyed web page in WebBrowser control in C# 如何在C#Winform上的WebBrowser控件中打开Word 2013文档? - How do I open a Word 2013 document in a WebBrowser control on a C# Winform?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM