直接打印RDLC报告而不向用户显示

时间:2013-11-12 22:15:01

标签: vb.net printing rdlc

我需要在用户(客户端)计算机上的默认打印机上打印RDLC报告。

我有一个拥有RDLC报告的VB.Net(VS 2008 / .Net 3.5)网络应用程序。部分要求是不向用户显示生成的报告,而是直接在用户默认打印机上打印。用户将单击按钮,相应的报告应发送到用户打印机。

任何想法或建议都会非常有用。

更新 - 到目前为止,我为rdlc报告构建客户端打印的所有尝试都失败了。无法从客户端默认打印机打印它们,只有服务器端打印工作

1 个答案:

答案 0 :(得分:1)

I have a solution for the rdlc printing directly without preview.
1. Convert the local report to word.
2. print the word document. You can pop up the print diaglog and let you choose the printer.
sample code like:

'Convert to word:
Dim bytes As Byte() = rptForm.ReportViewer1.LocalReport.Render("WORD", Nothing, mimeType, encoding, extension, streamids, warnings)

 Dim printDlg As New PrintDialog()
 Dim PrinterName as String
 If (printDlg.ShowDialog() = DialogResult.OK) Then
     PrinterName = printDlg.PrinterSettings.PrinterName
 End If

'Print the word document:
Dim appWord As New Word.Application
 appWord.Documents.Open(FullPath, m, m, m, m, m, m, m, m, m, m, m)
 appWord.WordBasic.FilePrintSetup(Printer:=PrinterName , DoNotSetAsSysDefault:=1)
 appWord.ActiveDocument.PageSetup.Orientation = WdOrientation.wdOrientPortrait
 appWord.ActiveDocument.PageSetup.PaperSize = WdPaperSize.wdPaperLetter
                    appWord.ActiveDocument.PrintOut()
                    appWord.Documents.Close()
                    appWord.Quit()
                    appWord = Nothing