【发布时间】:2014-04-25 11:45:04
【问题描述】:
Visual Studio 2010,Visual Basic.NET
我在表单上有一个 WebBrowser Control(wbImages),我需要允许用户打印该 WebBrowser Control 的内容。如果我使用 wbImages.Print(),它将打印文档,但只使用默认打印机。所以我想打开打印对话框以允许用户更改打印机。不幸的是,我不知道如何将 wbImages 的内容转换为 PrintDocument。
这是我目前拥有的。
Private Sub PrintToolStripMenuItem_Click(sender As System.Object, _
e As System.EventArgs) Handles PrintToolStripMenuItem.Click
'I need to get the wbImages into pdocImages
'pdocImages = ConvertPrintDoc(wbImages)
pdImages.Document = pdocImages
pdImages.PrinterSettings = pdocImages.PrinterSettings
pdImages.AllowSomePages = True
If pdImages.ShowDialog = DialogResult.OK Then
pdocImages.PrinterSettings = pdImages.PrinterSettings
If imageUrl.IndexOf(".jpg") <> -1 Or imageUrl.IndexOf(".gif") <> -1 Then
MessageBox.Show("Image has been sent to the printer.")
wbImages.Print()
Else
MessageBox.Show("Table has been sent to the printer.")
wbImages.Print()
End If
End If
End Sub
【问题讨论】:
-
不可能。您必须使用WebBrowser.Print() 方法。
-
所以用户在打印网页时永远无法更换打印机?
-
使用 WebBrowser.ShowPrintDialog()
-
哇,伙计,我很高兴你发布了这个!!!!像魅力一样工作,非常感谢!!!
标签: vb.net visual-studio-2010 .net-4.0