The data area passed to a system call is too small error-"when trying to print crystal report from server"

krishna 466 Reputation points
2021-08-12T07:26:36.057+00:00

I have a VB.NET application and I use crystal reports in it to send a report file directly to printer to print a document .When I run the application locally in development machine it works ,but when I run it after it is deployed in server and I print document ,I get "The data area passed to a system call is too small" error .Below is my code related to printing

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

With below code i am able to download the document to clients PC ,but issue comes when i try to print itenter code here

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
Community Center | Not monitored
{count} votes

Accepted answer
  1. krishna 466 Reputation points
    2021-08-18T05:20:08.93+00:00

    The problem was the length of the printer name ,before it was long eg:"HP Laser Jet M400 PCL 6" ,i reduced the printer name length in printer settings as "VHGPrinter" and crystal report was printing.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.