Help with printing...
Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1319
Printed Date: 03 May 2025 at 12:14am
Topic: Help with printing...
Posted By: danmir
Subject: Help with printing...
Date Posted: 14 Sep 2007 at 10:23am
Hello, this problem has haunted me for a long time, and I'm beginning to get nervous...
I'm running on windows XP, using VB 2005 and Crsytal Reports XI.
Well, I have a CrystalReportViewer embedded in a form, and I want that the user has two choices: see the report, or just send it to the printer... The CrystalReportViewer has a printReport method, but the problem is that it asks for confirmation of wich printer use.
I want to avoid this, just send it to the default printer, without prompting the user the print dialog.
Please Help!!
|
Replies:
Posted By: BrianBischof
Date Posted: 14 Sep 2007 at 12:50pm
I think there was a post about this a month ago. I forget what the answer was. You should search the forum to see comes up.
------------- Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
Posted By: danmir
Date Posted: 26 Sep 2007 at 11:38am
Thanks, well, I think this will do... I paste the code here so someone can have the answer:
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim prnOpts As CrystalDecisions.CrystalReports.Engine.PrintOptions
Dim ps As New PrinterSettings
repOPViewer.CrystalReportViewer1.ReportSource = repOPViewer.OPIntApo1
'here I put the report on display and all that
repOPViewer.CrystalReportViewer1.SelectionFormula = "{tblObras.Obr_intIdObra} = " & ordenProd.txtIdObra.Text
repOPViewer.CrystalReportViewer1.RefreshReport()
repOPViewer.Show()
'here I begin to print to the default printer
rpt = repOPViewer.CrystalReportViewer1.ReportSource
prnOpts = rpt.PrintOptions
prnOpts.PrinterName = ps.PrinterName
rpt.PrintToPrinter(1, True, 0, 0)
repOPViewer.Close()
Enjoy!!
|
|