开发者

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.

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!!


To get print preview from webbrowser control use

webBrowser1.ShowPrintPreviewDialog();

you can get a very good article in code project link http://www.codeproject.com/KB/cs/WBrowser.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜