I'm trying to send a report direct to the default printer and this is already running ok with this code:
doc.Load(Server.MapPath("~\\reports\\CrystalReport\\DocumentCRV.rpt"));
doc.SetDataSource(dsReport);
doc.PrintToPrinter(1, true, 0, 0);
The problem is that it only works when i'm running the webapplication on my dev machine (so, i'm assuming that it's getting the default printer for the server, not the user's printer)
There is no way to directly print to the users printer from the web server, unless possibly you are on the same internal network / directory. That would be a management nightmare.
Your best bet would be to pop open the viewer and then the print dialog.
I did use a active x control that could enumerate the end users printers and then automatically print it. However, it was IE only and poorly maintained.
Does the user have a default printer set up? Also, this article might help:
Choosing a printer when printing from Crystal Reports in C#
Controling user printers is not something that can be done from server-side code, as this would create potential security holes. The browser can be forced to print in JavaScript. Perhaps you could have the report be downloaded to the user? Then they can print from within a PDF viewer or something?
Related
So I have to RDP into my dev environment. From there, I've been trying to send a file to a Zebra label printer in RAW print mode. Similar to this post, the printer doesn't seem to receive anything. I'm using the same c# example code as a proof of concept. That leas to this, but this is already disabled in my group policies.
I am guessing I am just out of luck and have to copy to local as development occurs, but I was hoping not to have to do that.
We had the same problem on a Windows 2016 Server.
We solved it by changing the value of "Use Remote Desktop Easy printer driver first" in the Group Policy from "Not configured" to "Disabled".
This key is in the folder "Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Printer Redirection configurations".
I'm not sure if on the Computer or User configuration, or on both.
The redirect driver simply doesn't support it.
You can work around it by sharing the printer from your local an adding it that way. Then you can raw print to it.
My goal is to have a C# web forms app on Server 2012 R2 that converts text (and a picture) to PDF and sends it to a client. I have all of the code, just need to set up the printer correctly. The printer (PDF programe) has to be accesible via client-side browser (it sends the request, server creates the PDF with printer and sends it to client).
Whatever I try, the result is:
Unable to determine the application folder of the printer
'\server-name\Win2PDF'. Reinstalling the printer using the setup
program may fix the problem.
First step is to chose a free Text to PDF programe that works on Server 2012 R2 (because Microsoft Print to PDF doesn't for some reason). The only place my programe mentions the PDF programe is choosing printer name in code:
"PdfSettings.PrinterName = Win2PDF;".
Options so far:
Win2PDF - Best so far. Only adds an extra blank page to the document (acceptable).
CutePDF - Doesn't support .NET
bioPDF - Red watermark on the bottom
PDFsharp - I'd have to implement document-creating logic all over again (a lot of work)
Spire.PDF - Free trial
Win10PDF - Free trial, watermark
Second, I go to Print Managment, Print Servers, Printers, then choose the installed programe (Win2PDF), Properties:
Sharing: check "Share this printer"
Ports: not sure what to select so I enabled printer spooling and also checked an Standard TCP/IP Port (that i created earlier)
Security: I made sure every user there has permission to Print.
When I right click Win2PDF and go to List in directory I get:
The selected printer cannot be published. The directory service is unavalible.
I'm not sure what to do with Deploy with Group Policy.
I also enabled Branch Office Direct Printing for the hell of it.
Third, I made sure Printer Spooler is running. When I go to /System32/spool/PRINTERS I see an empty folder, is that a problem? Some people suggest trying to delete the contents of the PRINTERS folder, but I can't delete nothing. Also, after I installed the Spooling feature the article said to go to Server Manager, Print Services and see if Spooling is on the list (like this) and it's not on my list! Is that a problem?
I have no idea what's wrong or what to try next. Please help!
The answer is trying a different approach. I shouldn't have tried working with the virtual printer (i haven't found a way to make it work).
To create a PDF from code, the best way is using iTextSharp.dll. With that you need a handful of code (not much, but you got to know what you're doing).
Work on vs2005 Asp.net C# Application ,face problem on printer setup on my report. After deploy the application on server iis ,if I give print command from my local pc , rdlc report viewer page application run print command on my server pc’s default set printer but I want to print from my local pc’s default set printer.
I'd like to have a "Print" button on that page, which prints a specific set of information to the default printer attached to the client machine.
Is this possible from asp.net C#? I have found things online about printing to a printer attached to the server, but that's not really what I want. What I do?
Any type of suggestion will be acceptable, if have any query please ask. Thanks in advanced
You should let the user invoke the printing functionality from the browser, where they can control the printer and any other choices they might want (double-sided, landscape/portrait, etc.) If the default report format is better for presentation in the browser than printing, you can give them a link to a "printer friendly version" and let them print from there.
Its true, and never change as you want. The reason is crystal report is run on server, whenever you click button. So while print, it always print on the server's default printer, not client default printer.
This is the server side technology, now you want to print on client side.
The easiest way to any how you generate a HTML page and on that page run the print script which populate the list of printer on client machine, even if you run direct commant to print , it print on client's default printer.
Please check first this link : http://scn.sap.com/docs/DOC-52407
Here is some link if above not work
http://www.codeproject.com/Questions/262485/how-to-print-crystal-report-in-printer-in-client-m
Crystal Reports export to HTML
http://www.c-sharpcorner.com/UploadFile/chriswong1/ExportCrystalReportInASPNET11092005010905AM/ExportCrystalReportInASPNET.aspx
I need to print a Crystal report page to client printer machine without showing the report or without showing any dialog box.
One point I'd like to mention is that I know the name of Client Printer.
How do I send the path to that printer.
Just to make it clear the application runs on a server machine in a remote location.
There are some similar question here , but WITHOUT any final solution,like this one.
How to print crystal report without opening the report in asp.net?
Is there a specific solution to this that I can use ?
Below line opens up print dialog box to print without showing print preview
crystalReportViewer1.PrintReport();
Below line directly sends reportdocument to default printer.
oReportDocument.PrintToPrinter(1,true,0,0);
I have a web application in ASP.NET and c#. Is it possible to print in a particular printer attached to server for all print button click..??
Ie, If one clicks print button on client machine, the print is taken on the printer attached with the server....
If anybody knows this pls help me..... thanks in advance
What type of document do you want to print? The server would need a way to execute an application and call the print command.
There are a number of related questions on StackOverflow ->
I found a way to do something similar to what you described but it was far from easy.
When the user presses print the document requiring printing was written as a byte array to a database table that also had a "Printed" flag (false by default) and the name of the chosen printer.
On the server that hosted the database I built and added a windows service that polled the database table to see if there any documents on the table that had "Printed" set to false. If it found any it read the byte array and passed it on the the specified printer (setting the printed flag to true).
Problems
You have to give the service logon details with sufficient permissions to access the printer
Web services do not support the system.Printing or system.drawing.printing name spaces so I had to connect to the printer using TcpClient, the IP address of the printer and port 9100 (this is the default port for raw printing). I then passed the stream directly to the port. This worked but I only ever needed to print PDFs that my networked printer was able to support.
For more information on printing raw data see here
I don't recommend doing it exactly as I describe, but hopefully this might give you some ideas