I'm running into an extremely strange issue that a user of mine is reporting: A Crystal Reports report is printing blank pages past a certain point. My troubleshooting has sort of narrowed down the culprit, but at the same time, has displayed some inconsistent results.
Here's the lowdown:
The code that assigns the datasource to the report is as follow:
myCommand = New SqlClient.SqlCommand(strSQL, conPlanning)
myCommand.ExecuteNonQuery()
Da = New SqlClient.SqlDataAdapter(myCommand)
Da.Fill(dsData, "TempPrintLabels")
rptPrintLabels.SetDataSource(dsData.Tables(0))
rptPrintLabels.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait
frmReports.rptViewer.ReportSource = rptPrintLabels
frmReports.Show()
strSQL
is a basic SQL statement, based on which report is selected from this particular form. The report's SQL query is, SELECT * FROM TempPrintLabels
.
There's the basic info. The report generates fine, and for reports with ~100 labels, it prints fine. The strangeness happens when the report exceeds that limit; it's somewhere in the 95-120 label range. It doesn't seem to be consistent. The report will print, up until it hits that certain point. At that time, it will print nothing but blanks for the rest of the report. There will be as many blanks as there are supposed to be remaining pages. If you start the job again at the point where the blanks started, though, it prints fine.
When I look at this report in the CrystalReportViewer, it looks fine; all the labels render properly. When I print it to a PDF or text file printer, all the pages are there. So the report and print generation seems to be working to me.
I thought it was the printer. To test that, I printed a 185 page job to PDF, and then printed that to the printer. That printed absolutely fine.
I'm at a loss to explain this, or even diagnose this further. There is no code in the form for printing; it uses the CrystalReportViewer object to handle everything. If it was this CRV object, the printing to PDF should've given me blank pages. It didn't. If it was the printer, it should have started printing blanks from the PDF right around the same point as printing directly from the CRV object did. It didn't.
What else can I look for?
For this question, I have some thoughts which causes this behavior while printing.
It may the width issue of your all label's length exceeds from the page size. So you can check all the labels and pages are not blank when you shrink the width of labels (even labels not show properly, we can handle separately). If it shows not (as currently you getting), then you just handle labels width by "Can grow" option to true for all labels.
If everything fine, then I think you can check your printer's page setting / margin.
If above is not work, then either create new report or existing report with just adding static labels and values and then first preview and then call from code. Something you find with this.
As per my experience(I may be wrong in this case), whenever blank page comes in crystal report when your columns will increase, the report's width create an issue. So either set report width to decrease or set printer page bigger. So it print, other wise it not throw error, but give blank pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With