简体   繁体   中英

WebBrowser control: How to overwrite URL property

This is a bit special:
I'm loading some HTML in string form into the WebBrowser control via the DocumentText property.
Now when I print the page with a PDF printer (Bullzip PDF Printer in my case) it always takes the URL as document name which is "about:blank".
Is there any way to change this to another value by either changing the URL property (it's read-only) or by changing the print behaviour to use another text rather than the URL as filename?

There are a couple of options that I am aware of though my knowledge on this subject is a bit dated.

The first is to change the computer settings in Internet Options. Regardless of whether this is done by hand or through a registry change script, it is simple for the developer, but obviously not the best approach from the deployment or compatibility angles.

The next approach is to develop a custom print template. This is not fun, but is probably the most professional approach. As much as I would love to include all of the information needed on this approach in this post, it is too much to cover. Here is a good overview and good luck Googling from there.

My experience with this involved printing from the MS WebControl component used in a .NET 1.1 Winforms application to the Web Super Goo PDF converter component. Your mileage may vary.

您可以更改页眉和页脚,以便不打印URL属性。

尝试Navigate到一个URL,然后通过DWebBrowserEvents::BeforeNavigate取消该URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM