Printing Crystal report thro' ASp.Net
Hi,
I am develpoing an intranet application using ASP.Net which uses crystal reports. The IIS is installed in my machine. But the printer is connected to some other. When I try to take printout it raises an error as:
Error in File C:\DOCUME~1\banupriya\ASPNET\LOCALS~1\Temp\temp_2924ba53-898a-4038-a402-b1504cbdbe18.rpt: Request cancelled by the user.
The code I used is:
crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
crpt.PrintToPrinter(1, False, 1, 1)
Note: This code works when I connect & install the printer to my machine.
Can any one please say me how to fix this problem.
Thankyou for your reply.
reg
Banupriya
re: printing crystal report using asp dot net
Hi,
I am sending this again since I don't get any reply yet.
I am develpoing an intranet application using ASP.Net which uses crystal reports. The IIS is installed in my machine. But the printer is connected to some other. When I try to take printout it raises an error as:
Error in File C:\DOCUME~1\banupriya\ASPNET\LOCALS~1\Temp\temp_2924ba53-898a-4038-a402-b1504cbdbe18.rpt: Request cancelled by the user.
The code I used is:
crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
crpt.PrintToPrinter(1, False, 1, 1)
Note: This code works when I connect & install the printer to my machine.
Can any one please say me how to fix this problem.
Thankyou for your reply.
reg
Banupriya
Solution for Printer Problem
Dear Friends,
Iam sorry for the delay reply.
1. robinash, what you says is correct, the network printer won't recognize without network path.
2. if you want to view the installed printer list, refer the following code.
(But It's not a bug).
Code:
Imports System.Drawing.Printing
Dim fwPrintSetting As new System.Drawing.Printing.PrinterSettings
Dim nCnt As Integer
With cboPrinter.Items
For nCnt = 0 To (PrinterSettings.InstalledPrinters.Count - 1)
.Add(PrinterSettings.InstalledPrinters.Item(nCnt))
fwPrintSetting.PrinterName = fwPrintSetting.InstalledPrinters.Item(nCnt)
Next
End With
3. The reported error is
"Error in File C:\DOCUME~1\banupriya\ASPNET\LOCALS~1\Temp\temp_2924ba53-898a-4038-a402-b1504cbdbe18.rpt: Request cancelled by the user . "
a. Make sure the security permissions are correctly.
b. Do Testing printout from other reports.
Thanks.
Quote:
Originally posted by robinash
I think you didn't understand the problem. I have exactly the same.
It work fine with a local printer but if you want to use a printer on the network it doesn't work !
If he change the name of the network printer in the parameters his computer won't recognize the printer after this.
I think it's a bug (one more !!) of crystal !!
But if someone has the solution it could be great !!
Thanks
Nicolas
Re: Printing Crystal report thro' ASp.Net
I have tried all the possible solutions to this problem that were listed in the posts previews to this one and It simply doesnt work.
I have changed the Machine.cfg and made all the changes to the registry and It still doesnt work.
The code is very simple:
crystalReport.PrintOptions.PrinterName = @"\\Server\Server Printer";
crystalReport.PrintToPrinter(1,false,0,0);
But I still get the following Error:
CrystalDecisions.CrystalReports.Engine.InternalException: Error in File C:\WINDOWS\TEMP\temp_b29aeb15-c5f3-4426-a063-4edf6c5cb3b8.rpt: Request cancelled by the user.
If anyone has a solution for this that works Please post it thanks!
Re: Printing Crystal report thro' ASp.Net
Hi,
I have the same problems. I have modify my machine.config with userName="SYSTEM" and modifiy also my registry HKEY_USERS\.DEFAULT ... but I see still my local printer. I have reboot my machine, reregister aspnet.
Any other idea ?
Thank You
Re: Printing Crystal report thro' ASp.Net
i have the same problems.
I setup my Web application to print from a WebServer. I have setup the
account so that it can print correctly. However, it can only print if
the printer is connected to Win98 but if the
printer is connected to Win2000/XP, it throws an error:
Error in File xxx Request cancelled by the user.
Here is my code to print over the web:
Dim x As ReportDocument = New ReportDocument()
x.PrintOptions.PrinterName = "xxx"
x.PrintToPrinter(1, True, 1, 1) '(eror on this line)
Please give me a solution
thank u all
Re: Printing Crystal report thro' ASp.Net
Hi achonk81 and all!!
Not sure this may help you, but this is how I solved the problem:
Instead of trying to print the crystal report by using PrintToPrinter method, I export immediately the report in PDF. After the export, the report will be viewed in Acrobat Reader, and the user will be able to save the report wherever he wants or to print it, and he can choose on which printer he wants to print the report, comparing with the PrintToPrinter method for which you must specify a printer. And PDF display the report as you designed it, with page break. It is much more user friendly than the crystal report web viewer and really less trouble. Here the web site where I found how to export the report in PDF. If you put directly the code in the Page_Load function, the report will open by default in PDF.
http://www.c-sharpcorner.com/Code/20...rtInASPNET.asp
Hope this help and that I'm not too late
Mara
Re: Printing Crystal report thro' ASp.Net
thanx mara jade for your suggestion.
But in this case i want to print invoice so i need to print directly to the printer insteadly view the report first. if you have other suggestion i will be gratefull
Re: Printing Crystal report thro' ASp.Net
A solution we have implemented for this problem is if the printer itself has a network address.
Add the printer as a local printer to your web server box connected by a Standard TCP/IP port.
With the Add Printer Wizard
1) Select Local Printer
2) Choose to "Create a new port"
3) Select Port Type: "Standard TCP/IP Port"
4) Provide the IP address for the printer
5) Select the appropriate printer driver
6) Give the Printer the desired name, ie. "TESTPRINTER"
This will allow you to send your reports directly to a networked printer without a need to provide the server name from which the printer is accessible by using the standard
Report.PrintOptions.PrinterName = "TESTPRINTER"
It doesn't necessarily allow you to access a printer on another server but it does allow you to send print jobs directly to a networked printer with is typically the desired end result.
Re: Printing Crystal report thro' ASp.Net
Hi, I did a search in Google for this solution and found your posts. You saved me alot of time by trying all those things they suggested. I'm not sure if you figured it out since it was last year but I found the solution. I just started working with Crystal in .NET. Anyway all you have to do is:
You were right in trying to assign it this way.
crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
It kept giving a problem because it was intrepreted this way:
crpt.PrintOptions.PrinterName = "\banupriyahp LaserJet 1300 PCL 6"
What you have to do is assign it this way:
crpt.PrintOptions.PrinterName = "\\\\banupriya\\hp LaserJet 1300 PCL 6"
Each set of "\\" represents one "\" so since you need 2 "\\" in the beginning you have to initialize it with 4 "\\\\" so it can be intrepreted like this:
crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
Re: Printing Crystal report thro' ASp.Net
same i am trying from nearly 3 months but i didnt get any solution.
I am printing a file to a network printer from webservice which is running from IIS. When i execute the code directly from Visual Studio it prints but when i execute by putting URL in addressbar ie running through IIS it does not prints. But it prints on local printer.
The second thing is i have given all rights to aspnet user also iwam user.
Printer is shared also have given full control to everyone. Also i hav tried all things mentioned above. As my company is Microsoft gold partner we hav put this case on their helpdesk but i am strange that they are also not able to find a solution on this.
I m fed up now tried everything given all rights to all things where security is define..windows authentication is also enabled for VD and anonymous user is enabled.
Any one knows the correct solution???