使用VB .NET从Internet Explorer打印pdf [英] Print pdf from Internet Explorer using VB .NET

查看:111
本文介绍了使用VB .NET从Internet Explorer打印pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个程序执行以下操作:

当用户点击VB.NET数据网格中的一行时,它将会在

Internet Explorer中打开一个网页(对应于

数据网格中所选行中的那个项目)。它将自动打印该网页,然后它将关闭Internet Explorer窗口的
。当打开

常规网页时,我的代码非常有效,但是当打开pdf网页时,

打印永远不会发生。任何帮助将不胜感激。数据网格的原因是,最终用户应该能够选择许多

行,并且无需任何用户干预即可打印所有网页。谢谢

你! Mrs_Mcse


我的VB.NET代码是:


如果DataGrid1.IsSelected(0)= True那么


Dim selectedItem As Object

selectedItem = DataGrid1.Item(0,4)

''出于测试目的,只需使用datagrid中的第一行

并使用包含网址的第4列

Dim cellValue As String

cellValue = selectedItem


Dim Explorer As SHDocVw.InternetExplorer

Explorer = New SHDocVw.InternetExplorer

Explorer.Visible = True

Explorer.Navigate(cellValue)




循环直到Explorer.Busy = False


Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,

SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)


结束如果

Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
''For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If

推荐答案

Wendy写道:
您好,

我有一个程序执行以下操作:
当用户点击ar时在VB.NET数据网格中,它将在Internet Explorer中打开一个网页(对应于
数据网格中所选行中的该项目)。它将自动打印该网页,然后它将关闭Internet Explorer窗口。我的代码在打开常规网页时效果很好,但是当打开pdf网页时,
打印永远不会发生。任何帮助将不胜感激。数据网格的原因是,最终用户应该能够选择许多行,并且无需任何用户干预即可打印所有网页。谢谢
你! Mrs_Mcse

我的VB.NET代码是:

如果DataGrid1.IsSelected(0)= True那么

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0,4)
''出于测试目的,只需使用数据网格中的第一行
并使用包含网址的第4列
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)<执行

循环直到Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

结束如果
Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
''For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If




为什么不在vb.net中托管页面而不是启动IE?那么你

可以自己打印。


克里斯



Why not host the page inside vb.net instead of launching IE? Then you
can print it yourself.

Chris


嗨克里斯,


对不起,但这是我所知道的唯一方式。你能否告诉我,至少在一般情况下,b $ b,如何完成你的建议?


非常感谢你,


Wendy


" Chris"写道:
Hi Chris,

Sorry, but this is the only way that I know. Would you please tell me, at
least in general terms, how to accomplish what you suggest?

Thank you so much,

Wendy

"Chris" wrote:
Wendy写道:
你好,

我有一个程序执行以下操作:
当用户点击VB.NET数据网格中的一行,它将在Internet Explorer中打开一个网页(对应于
数据网格中所选行中的该项目)。它将自动打印该网页,然后它将关闭Internet Explorer窗口。我的代码在打开常规网页时效果很好,但是当打开pdf网页时,
打印永远不会发生。任何帮助将不胜感激。数据网格的原因是,最终用户应该能够选择许多行,并且无需任何用户干预即可打印所有网页。谢谢
你! Mrs_Mcse

我的VB.NET代码是:

如果DataGrid1.IsSelected(0)= True那么

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0,4)
''出于测试目的,只需使用数据网格中的第一行
并使用包含网址的第4列
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)<执行

循环直到Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

结束如果
Hello,

I have a program that does the following:
When a user clicks on a row in a VB.NET datagrid, it will open a web page in
Internet Explorer (that corresponds to that item in the selected row in the
datagrid). It will automatically print that web page, and then it will close
the Internet Explorer window. I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs. Any help would be greatly appreciated. The reason
for the datagrid is that ultimately the user should be able to select many
rows and have all the web pages print without any user intervention. Thank
you! Mrs_Mcse

My VB.NET code is:

If DataGrid1.IsSelected(0) = True Then

Dim selectedItem As Object
selectedItem = DataGrid1.Item(0, 4)
''For testing purposes, just use the first row in the datagrid
and use column 4 that contains a web url
Dim cellValue As String
cellValue = selectedItem

Dim Explorer As SHDocVw.InternetExplorer
Explorer = New SHDocVw.InternetExplorer
Explorer.Visible = True
Explorer.Navigate(cellValue)
Do

Loop Until Explorer.Busy = False

Explorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPRE VIEW,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER)

End If



为什么不在vb.net中托管页面而不是启动IE?然后你就可以自己打印了。

Chris



Why not host the page inside vb.net instead of launching IE? Then you
can print it yourself.

Chris





" Wendy" ; <我们*** @ discussions.microsoft.com>在消息中写道

news:45 ********************************** @ microsof t.com ...

"Wendy" <We***@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
我的代码在打开
常规网页时效果很好,但是当打开pdf网页打印时
打印永远不会发生。
I have code that works perfectly when a
regular web page is opened, however when a pdf web page is opened the
printing never occurs.




这不是因为你需要使用pdf打印功能而不是IE

打印功能吗?也许您需要找到一种方法将该消息发送到

pdf display addon。



Isn''t that because you need to use the pdf printing function and not the IE
printing function? Perhaps you need to find a way to send that message to
the pdf display addon.


这篇关于使用VB .NET从Internet Explorer打印pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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