Report previews correctly, but direct save of PDF comes up blank

2 Answers 267 Views
Report Viewer - WinForms
Phil
Top achievements
Rank 1
Iron
Phil asked on 07 Jun 2021, 06:46 PM | edited on 07 Jun 2021, 06:51 PM

I am using Telerik reporting in a VB.net app.  The reports each preview correctly, but if I print directly to a printer, it comes up blank.  To PDF it saves a blank file.  To a physical printer, it goes through the motions with the driver, but nothing is actually printed.

Telerik.Reporting.dll is version 15.0.21.326.

What am I missing?

code below:

Public Sub SaveReport(ByVal myreport As Telerik.Reporting.Report, filename As String)
       
        Dim reportProcessor As Telerik.Reporting.Processing.ReportProcessor = New Telerik.Reporting.Processing.ReportProcessor()
        Dim instanceReportSource As Telerik.Reporting.InstanceReportSource = New Telerik.Reporting.InstanceReportSource()
        instanceReportSource.ReportDocument = myreport
        Dim renderingResult As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, Nothing)
        Dim fs As FileStream = New FileStream(filename, FileMode.Create)
        fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length)
        fs.Close()
    End Sub

 

Public Sub PrintReport(ByVal myreport As Telerik.Reporting.Report, ByVal Copies As Integer)
        strModErr = "Module1_PrintReport"
        Dim printerSettings As PrinterSettings = New PrinterSettings()
        Dim printController As PrintController = New StandardPrintController()
        Dim reportProcessor As ReportProcessor = New ReportProcessor()
        Dim instanceReportSource As Telerik.Reporting.InstanceReportSource = New Telerik.Reporting.InstanceReportSource()

        Try
            instanceReportSource.ReportDocument = myreport
            printerSettings.PrinterName = My.Settings.DriverLogPrinter
            printerSettings.Copies = Copies
            reportProcessor.PrintController = printController
            reportProcessor.PrintReport(instanceReportSource, printerSettings)
        Catch ex As Exception
            WriteErrorToLog(Err.Number, strModErr + " - " + Err.Description)
            Dim inner As Exception = ex.InnerException
            Do
                If inner IsNot Nothing Then
                    WriteErrorToLog(666, inner.GetType().Name + ": " + inner.Message)
                    inner = inner.InnerException
                End If
            Loop While inner IsNot Nothing

        End Try
    End Sub
   

2 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 08 Jun 2021, 01:03 PM

Hello Phil,

I am sorry to hear about the issues with print and export functionality and will try to help you figure out what is causing the troubles and fix it.

As you mentioned, the preview is working correctly and the issue is with the export to PDF and printing directly. The result from the export and print is a blank document. This could be caused by some kind of miscommunication between the ReportProcessor and the actual ReportDocument that you are referencing. If the ReportDocument is not found, this will result in a blank document during the export, so make sure that the ReportDocument is not blank or not even read.

In order for me to continue investigating this issue, I will need your help. Please attach a Trace Listener to the configuration file of the application and send us the generated log. I will analyze the log and try to advise you further. In addition to that, prepare a runnable sample project that reproduces the issue and attach it to this thread. That will help me reproduce the issue and debug it on my end. Thank you in advance!

And lastly, I believe that the following two links will be helpful to you and are worth exploring. Both have information about exporting the report, like how to programmatically export a report and use the report engine and how to print a report directly on the client-side.

I am looking forward to hearing from you.

Regards,
Plamen Mitrev
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
0
Phil
Top achievements
Rank 1
Iron
answered on 09 Jun 2021, 12:03 PM
After further review...I forgot to assign the datasource to the report..  Then I copied the code to three different places...sorry.
Plamen Mitrev
Telerik team
commented on 10 Jun 2021, 08:53 AM

If I understand correctly, you managed to resolve the issue and it was related to the data source. Now the report is not blank, when you export it to PDF or print it directly.

Please do not hesitate to contact us again, if there are any troubles and I will be happy to assist you.

Tags
Report Viewer - WinForms
Asked by
Phil
Top achievements
Rank 1
Iron
Answers by
Plamen Mitrev
Telerik team
Phil
Top achievements
Rank 1
Iron
Share this question
or