开发者

Printing into a particular printer on c#

开发者 https://www.devze.com 2023-02-20 11:08 出处:网络
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..??

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 m开发者_JAVA技巧e..... 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

0

精彩评论

暂无评论...
验证码 换一张
取 消