Print a Report in Landscape with VB.NET using Crystal Reports Viewer

I am using VB.Net 2005 and CR 11.5    Trying to give the user two options, either Preview or Direct Print.  I can get the Preview to work easily by using the .Show() method.  Problem is when I try to bypass the preview mode and send the report instead directly to the printer, it ends up printing any report in Potrait Orientation, even if the report is designed and designated as Landscape.

Currently using the objCRViewer.PrintReport() method, which brings up the printer selection dialog box.  I also tried bringing up my own MS Print Dialog and passing the parameters to the objReport.PrintToPrinter() method, but I keep getting a "Missing Parameters" error, but of course doesn't tell me what is missing.  Please help!
rev0304Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
What code are you using?

I have found that reports switch properly between portrait and landscape if the printer defaults to landscape rather than portrait.  Not sure if that was the printer we used or if it is true for all printers.

mlmcc
rev0304Author Commented:
The code I am running is below, of course in context to the rest of my application.

There are two Print lines, one using the CRViewer [.PrintReport()] and the other using the Report Object [.PrintToPrinter()]... I commented out both lines

Hope this helps.
        '***************************************
        ' Initialize Variables
        '***************************************
        Dim objPrintDialog As New PrintDialog
 
        '***************************************
        ' Default Values
        '***************************************
        With objPrintDialog
            .AllowCurrentPage = False
            .AllowPrintToFile = False
            .AllowSelection = False
            .AllowSomePages = False
            .ShowDialog(Me)
        End With
 
        '***************************************
        ' Attach Data To Report
        '***************************************
        With Me._objReport
            .SetDataSource(Me._objDataSet)
            .Refresh()
        End With
 
        '***************************************
        ' Re-Instantiate Preview Form If Needed
        '***************************************
        If IsNothing(Me._objCRPreviewForm) OrElse Me._objCRPreviewForm.IsDisposed Then
            Me._objCRPreviewForm = New frmCrystalPreview
        End If
 
        '***************************************
        ' Print Report
        '***************************************
        With Me._objCRPreviewForm
            If Not IsNothing(Me._objParamFields) Then
                .CRViewer.ParameterFieldInfo = Me._objParamFields
            End If
            .CRViewer.ReportSource = Me._objReport
            With Me._objReport
                .PrintOptions.PrinterName = objPrintDialog.PrinterSettings.PrinterName
                '.PrintToPrinter(objPrintDialog.PrinterSettings.Copies, objPrintDialog.PrinterSettings.Collate, 0, 0)
            End With
            Me.Message_Close()
            '.CRViewer.PrintReport()
            .Dispose()
        End With

Open in new window

mlmccCommented:
Does your report require parameters?

mlmcc
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

rev0304Author Commented:
Some do, not all of them.
mlmccCommented:
The REFRESH drops the parameters.  Try deleting that line

mlmcc
rev0304Author Commented:
I think you misunderstood, the parameters missing error I am getting is a VB IDE error regarding the PrintToPrinter() method, it is not a Crystal Error regarding report parameters. I am aware that .Refresh() drops parameters, which is why, if you noticed, I use the .Refresh() before I apply the parameters so that way I do not lose them.  But all in all, the Parameters are not my problem, they work perfectly fine.  My problem is being able to print in Landscape.
mlmccCommented:
It may be the nested WITH structure.  Try fully qualifying the PrintToPrinter.

mlmcc
rev0304Author Commented:
Nope, that didn't fix it.  :-(
mlmccCommented:
Is the printer dialog displayed or open?

mlmcc
rev0304Author Commented:
Yes the Printer Dialog displays perfectly fine.
mlmccCommented:
Is it still open when you try to reference it?

mlmcc
rev0304Author Commented:
If you are asking if I disposed the object, no.  The code above shows you that.  But it's a moot point, because the problem of not being able to directly print in Landscape happens using the PrintReport() method also, which uses it's own PrintDialog box.  The problem I am having ultimately is not a coding problem, but rather I think it's a Crystal problem.  Either Crystal has a bug, or there is an additional setting that I am unaware of to get it to print the way it should.
mlmccCommented:
No, since you are pulling information from the Printer Dialog, it must be open to use the information.  Generally once displayed to get off of it you click OK and it closes.

I have found that to get reports to print in landscape, the printer must be set to landscape as default.
For some reason reports switch to portrait with no problem but switching to landscape doesn't seem to work.

mlmcc
rev0304Author Commented:
That is unfortunate...since the software I am developing can use a multitude of printers, from a variety of clients.  Switching the printer itself to default to Landscape is not an option.  Then I see that my supposition was correct, Crystal has a bug in in with regards to printing in Landscape directly to printer without first previewing the report.  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.