Web浏览器控件不会在类库中打印内容 [英] Web Browser Control will not print contents in a class library

查看:65
本文介绍了Web浏览器控件不会在类库中打印内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类库,在这个类库中我创建了一个Web浏览器控件,向其添加html然后调用print函数。



这不是'似乎打印任何东西,我想知道是否有人可以帮助我?

这样做作为一个Windows应用程序似乎工作正常但是只要我将它转换为类库它似乎不喜欢它。

我听说(因为我正在寻找答案),在类库中你不能从Web浏览器控件打印。



如果是这样的话我怎样才能完成(另一种方式)打印html页面的相同任务?



这是我的代码:

 私人 功能 StartPrint( ByVal  htmlstring  As   String 作为 整数 
尝试
Dim objbrowser As New WebBrowser
objbrowser.DocumentText = htmlstring
objbrowser.Print()
objbrowser.Dispose()
返回 0
Catch ex As 除外ion
返回 -1
结束 尝试
结束 功能





谢谢。

解决方案

WebBrowser控件必须放在表单上才能工作

I have a class library and in this class library I create a web browser control, add html to it and then call the print function.

This doesn't seem to print anything and I wonder if someone could help me?
Doing this as a windows application seems to work fine however as soon as I convert it to a class library it doesn't seem to like it.
I heard (as I was searching for an answer) that in a class library you cannot print from a web browser control.

If this is the case how could I accomplish (an alternative way) the same task of printing an html page?

Here is my code:

Private Function StartPrint(ByVal htmlstring As String) As Integer
     Try
         Dim objbrowser As New WebBrowser
         objbrowser.DocumentText = htmlstring
         objbrowser.Print()
         objbrowser.Dispose()
         Return 0
     Catch ex As Exception
         Return -1
     End Try
 End Function



Thank-you.

解决方案

The WebBrowser control MUST be put on a form in order to work.


这篇关于Web浏览器控件不会在类库中打印内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆