Printing into a particular printer on c# - c#

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

Related

What are the purposes of these three connection options for printing the label in ZPL?

I have these three radio button inside the group box named Printer Connection in the windows form:
a. Network
b. Serial
- dropdownlist
c. Web service
User has to choose one of the option from above before printing any labels or clicking the button Print Label. If someone would explain about the purpose of web service and the scenario how it can be utilize to connect to the printer and printing label. Thank you!
It is hard to understand what app you are using but I have to imagine you are using something based off of the Java SDK by Zebra. In this SDK there is a Web Services SDK. It comes with a .war file that gets added to a Tomcat server. Printers have a set of settings which when configured will have the pritners establish a connection to the server with the .war file installed. Once the printer has connected you can use the Java SDK functions to communicated with the printer from that server.
This explanation is probably over simplified, but if you look through the help documentation on the SDK you will probably get a better explanation.

How to configure Text to PDF programe as Printer in Server 2012 to be used on server for creating PDF's

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).

Is it possible to print from local pc default printer?

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

Remote and local printing from a C# ASP.NET application

My situation involves an ASP.NET application that I have written which should remotely print orders, as well as print a local copy for the person creating the order on the local client machine.
The process works like this: once an order has been created in previous pages and is submitted into the system, the order information is first permanently stored into an Oracle database table. The application then carries the user to a printer-friendly order page with the final order displayed and ready to print. An order page consists of some title text at the top, places for signatures and dates, and finally, a GridView object containing the information about the order (item category, item subcategory, and quantity for each ordered item).
Once this page has finished loading and is ready for printing, I need the system to do two things:
Print the order information page to the default local printer on the client computer, or else call up the print dialog to allow the user to print the order information.
Print the order information to a remote printer (with a known, static IP address) located elsewhere on our network where the orders get processed.
Printing to the local machine is easy to figure out, of course. I had intended to simply call the default print dialog and allow the user to print from there, or to do some similar function to allow the webpage to print locally. The difficulty comes in figuring out how to print to the remote computer. All I have available to me to specify that printer to the system is its static IP address. I don't have the shared name of the printer.
Given this information, is it possible to have the webpage print automatically on the remote printer where the orders get processed? If so, what do I need to use to do it? Also, if anyone has some sample code that might help get me started (in either VB or C#, although this project's back-end code is in C#), it would be extremely appreciated.
Thanks!
I've once implemented such a thing but the user that's running your ASP.net application should have enough rights to print (which it doesn't most of the time for obvious reasons). What I had done in order to fix this is create a client web service that accepts the document to print and sends that (it is installed on a machine in the same domain as the printer) to the printer.

Crystal report to send report directly to default printer

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?

Categories