The ReportDocument class provides PrintToPrinter method that may be used to print a CR direct to the printer. If no printer is selected, the default printer will be used to send the printing pages to.
The PrintToPrinter method takes four parameters.
nCopies : Indicates the number of copies to print.
collated : Indicates whether to collate the pages.
startPageN : Indicates the first page to print.
endPageN : Indicates the last page to print.
The following steps will guide you to achieve the same:
- Add a crystal report (.cr) file to your ASP.NET application.
- Add a report instance on the page level.
- Dim report As MyReport = New MyReport
- Populate reports data on Page_Init
- ' Get data in a DataSet or DataTable
- Dim ds As DataSet = GetData()
- ' Fill report with the data
- report.SetDataSource(ds)
- Print Report
- report.PrintToPrinter(1, False, 0, 0)
If you wish to print a certain page range, change the last two parameters From To page number.
If you want to set page margins, you need to create a PageMargin object and set PrintOptions of the ReportDocument.
The following code sets page margins and printer name:
- Dim margins As PageMargins = Report.PrintOptions.PageMargins
- margins.bottomMargin = 200
- margins.leftMargin = 200
- margins.rightMargin = 50
- margins.topMargin = 100
- Report.PrintOptions.ApplyPageMargins(margins)
- ' Select the printer name
- Report.PrintOptions.PrinterName = printerName

brijendra sharmaPosted Sep 27, 2011, 9:12 PM EDT
hi mani, report.PrintToPrinter(1, False, 0, 0) this code doesn't work on server its works fine on localhost... and what is the purpose to add script manager?
brijendra sharmaPosted Sep 27, 2011, 2:53 AM EDT
report.PrintToPrinter(1, False, 0, 0) this code doesn't work while i deploy the application on iis server.. please help
Anirban KunduPosted Feb 10, 2011, 8:44 AM EST
Hi Mahesh, I am trying to print a Crystal report thru a WCF service. When I am running the WCF service in a stand alone mode the Crstal report is getting printed correctly. Now when a client is trying to call that service [which in turn prints the report], is giving the following error : "RPC server not available". Stach Trace : at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) at System.Drawing.Printing.PrintController.Print(PrintDocument document) at System.Drawing.Printing.PrintDocument.Print() at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at CISPrintService.PrintService.DoBatchPrint(PrintDC PobjPrintDC) in C:\Inetpub\wwwroot\CISPrintService\PrintService.svc.cs:line 91 I have checked all the following service is up & running: 1)Printer Spooler 2) RPC 3) RPC Locator Could you please help me in this regard? Thanks, Anirban
Zehan JurangpathyPosted Dec 11, 2010, 6:26 AM EST
Hi, I have a crystal report which i created for my POS system. Is there a way to automatically grow the size of the Details section of the report depending on the amount of rows that are going to be added to the report. It's really very urgent. Plz reply, Thanks in advance, Zehan
Ravi PolaPosted Sep 1, 2010, 11:14 PM EDT
Hi, I have an application which is developed on VS 2005, and I am able to take a Printout which is designed in Crystal Reports which comes with VS2005 Default. But when I host the same app on the Server, then I am unable to take the Printout. The Images on CR is showing Cross Marked. Please suggest me on the same. Thanks in Advance. RaviPola.
Mani maranPosted Jul 22, 2010, 10:42 PM EDT
i'm using crystal reports in Asp.Net with C#. But in this Print Button is not working.
Maulik PatelPosted Jul 12, 2010, 7:59 PM EDT
Hi, I did this code to my project but it is working only on local machine it is not working on server. Please, Help Me. Thank You, Maulik
Aravind GovindarajPosted Apr 5, 2010, 1:39 AM EDT
Dear Sir, I have a doubt in print receipt, I created one application which shows data fully in crystal report and it print in A4 sheet. I dont want like that , i want to print data as like as a Medical Shop billing Paper. I think you may understand what i am trying to say. Looking for your Anticipation reply Thanks and Regards Aravind G [email protected] Chennai
Sri WunonPosted Jun 25, 2009, 2:58 AM EDT
Hi All, Do you have any snippet code to print crystal report in client side? Thanks.
sapna raiPosted May 31, 2009, 9:49 PM EDT
Hello All of You, I am sapna,I have problem of print crystal report on server .when i Click on print option it is not tak any action please help me [email protected]
Shashank ChaudharyPosted Oct 21, 2008, 10:55 PM EDT
hi, I m shashank, my problem is that I want to print current values of web page in the form of bill by using the crystal report and also want to add the same values in the database by clicking the single button please help me........
a aaPosted Jan 11, 2008, 4:43 AM EST
Hi , Using VS 2005 with integrated crystalreport On my computer is good developer parameters can be taken into consideration. But when I deploys on a client with clickonce I get an error on the reports with parameters Thanks
Mehul PatelPosted Nov 7, 2007, 10:41 AM EST
Hi Mahesh, I am getting error of Load report failed when I try to access crystal report using my asp.net application, can you give me one solution.
riyaz khanPosted Nov 6, 2007, 12:49 AM EST
hi have u finish the client side printing successfully if means can u send the method to me??? i hope soon regards riyaz
atiyeh darziPosted Aug 18, 2007, 10:37 PM EDT
i want to print report with print Button in web site but when i click this button show java script error why? please help mi. thanks
partha sarathyPosted Aug 3, 2007, 3:28 AM EDT
Hello experts.. Please help me.. I need to print last page of data using Crystal Report. Please reply me have any idea as soon as possible. Thank you
shirish padekarPosted Aug 1, 2007, 1:38 AM EDT
Hi I am currently working on a VB.NET project with following requirements : Suppose I have to print .doc file having 10 pages using VB.Net program and after clicking on print button,suppose printer finishes printing 6 pages and then suddenly printer is out of papaer/light is off ,etc. then if I check the printer properties then it should not show remaining 4 pages in the queue. i.e. Generally what happens is that first 10 pages are taken into buffer of printer and then printing starts. But problem is that if printing operation stops due to some reason, then remaining pages will be in buffer. So I dont want that all pages should be in buffer.I want to print these pages one by one, so that if printing is stopped due to some reason then there should be no pages in queue. So how it can be done using vb.net programming
dan buenvenidaPosted Jun 7, 2007, 10:17 PM EDT
Hi Mr. Mahesh. May I know what are the namespace I need to include? Coz I have the following errors - 1. Dim DS As DataSet = GetData() -Name GetData is not declared 2. MyReport does not appear on the intellisense. Thanks
MunishPosted May 14, 2007, 4:11 AM EDT
Is it possible to set Paper Style in Crystal Report through AP.net. I want to set Paper Type eg. Fanfold 15 X 12 in for all report.
nupur jayavantPosted Apr 26, 2007, 8:32 PM EDT
how will i do this for windows based application? Please provide me the solution i need it urgently
suresh kumarPosted Apr 12, 2007, 1:08 AM EDT
hi i am suresh, i need to print crystal report from web page.
shylaja bantuPosted Mar 22, 2007, 4:32 AM EDT
how to connect from gridview to crystalreport directly thatmeans we are adding columns in gridview dynamically so with those columns we have to generate crystal report dynamically
akilaPosted Mar 20, 2007, 6:07 PM EDT
hi, Printtoprinter method is printing on serverside.But I want to print directly on client side printer.it is very urgent.Please help me.I need to print from web based POS BIll system. Thanks, Akila
kavitaPosted Oct 26, 2006, 12:39 AM EDT
hi I m kavita,My problem is L want to go another page when I click a row in crystal report suppose I have 100 row in my report n when I click a Row I want to go detail page is it possible please help me [email protected]