【发布时间】:2021-08-12 07:10:22
【问题描述】:
我有一个 VB.NET 应用程序,我在其中使用水晶报表将报表文件直接发送到打印机以打印文档。当我在开发机器上本地运行应用程序时它可以工作,但是当我运行它之后部署在服务器中,我打印文档,我得到“传递给系统调用的数据区域太小”错误。下面是我与打印相关的代码
Dim ObjDoc As New ReportDocument()
lsOrgDup = "D"
cocPrinting.FetchReportDataforUTDoc1(row.Cells(4).Text.ToString().Trim(), row.Cells(5).Text.ToString().Trim(), row.Cells(6).Text.ToString().Trim(), row.Cells(3).Text.ToString().Trim(), row.Cells(2).Text.ToString().Trim(), row.Cells(7).Text.ToString().Trim(), lsOrgDup, cdtUTDoc01, lsErr)
ObjDoc.Load("Crystal_Reports//VHRSSALEPDU001.rpt")
ObjDoc.SetDataSource(cdtUTDoc01)
If cEnvironment.Production = psEnvironment Then
If CheckifPrinterInstalled(row.Cells(9).Text.ToString().Trim()) = True Then
ObjDoc.PrintOptions.PrinterName = row.Cells(9).Text.ToString().Trim()
ObjDoc.PrintToPrinter(1, False, 0, 1)
lsPrintMessage = lsPrintMessage & "Pre Delivery Document has been sent to printer" & " \r\n"
Else
lsPrintMessage = "This printer " & row.Cells(9).Text.ToString().Trim() & " is not installed for this PC,cannot print"
End If
End If
使用以下代码,我可以将文档下载到客户端 PC,但是当我尝试打印时出现问题
If cEnvironment.Development = psEnvironment Then
Dim formatType As ExportFormatType = ExportFormatType.NoFormat
formatType = ExportFormatType.PortableDocFormat
ObjDoc.ExportToHttpResponse(formatType, Response, True, "Undertaking Doc")
Response.End()
End If
【问题讨论】:
-
我找到了导致问题的行“ObjDoc.PrintOptions.PrinterName = row.Cells(9).Text.ToString().Trim()”,如果我们设置打印机名称上述错误发生
标签: vb.net printing crystal-reports