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 28, 2011, 1:12 AM
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, 6:53 AM
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, 1:44 PM
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, 11:26 AM
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 2, 2010, 3:14 AM
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 23, 2010, 2:42 AM
i'm using crystal reports in Asp.Net with C#. But in this Print Button is not working.
Maulik PatelPosted Jul 12, 2010, 11:59 PM
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, 5:39 AM
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, 6:58 AM
Hi All, Do you have any snippet code to print crystal report in client side? Thanks.
sapna raiPosted Jun 1, 2009, 1:49 AM
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 22, 2008, 2:55 AM
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, 9:43 AM
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, 3:41 PM
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, 5:49 AM
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 19, 2007, 2:37 AM
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, 7:28 AM
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, 5:38 AM
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 8, 2007, 2:17 AM
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, 8:11 AM
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 27, 2007, 12:32 AM
how will i do this for windows based application? Please provide me the solution i need it urgently
suresh kumarPosted Apr 12, 2007, 5:08 AM
hi i am suresh, i need to print crystal report from web page.
shylaja bantuPosted Mar 22, 2007, 8:32 AM
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, 10:07 PM
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, 4:39 AM
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]