Skip to Content
Mar 06, 2022 at 12:21 PM

Load Report Failed-when trying to print crystal report with web service

130 Views Last edit Mar 07, 2022 at 02:43 PM 3 rev

I am trying to print a crystal report by sending report to printer directly with the help of a webservice .However i get Load Report error.This was a working code in wpf application .I just took the printing part of the code to a web service so that i dont have to install printer in every client PC as I have about 300 users.I have given full access to read/write for the folder to Everyone,Local Service,Network Service.Web service is asmx ,soap based .My code is below

 <WebMethod()> _
    Public Function PreDeliveryDocument(ByVal ldtDetails As DataTable, ByVal lsPrinterName As String, ByVal lsDocType As String) As String
        Dim ObjDoc As New ReportDocument()
        ObjDoc.Load("//Server Name//Crystal_Reports//VHRSSALEPDU001.rpt")//shared location code working in WPF App
        'ObjDoc.Load("D:\\Crystal_Reports\\VHRSSALEPDU001.rpt")//Tried this but same error
        'ObjDoc.Load("D://Crystal_Reports//VHRSSALEPDU001.rpt")//Tried this but same error<br>

        ObjDoc.PrintOptions.PrinterDuplex = PrinterDuplex.Default

        If CheckifPrinterInstalled(lsPrinterName.ToString().Trim()) = True Then
            'ObjDoc.PrintOptions.PrinterName = row.Cells(9).Text.ToString().Trim()
            ObjDoc.PrintOptions.PrinterName = lsPrinterName.ToString().Trim()
            ObjDoc.PrintToPrinter(1, False, 0, 0)
            Return "Pre Delivery Document " & lsDocType.ToString().Trim() & " has been sent to printer " & lsPrinterName.ToString().Trim() & " \r\n"
            Return "This printer " & lsPrinterName.ToString().Trim() & " is not installed on server,cannot print"
        End If

    End Function