简体   繁体   中英

Send a Print Job to a Computer

So say I have a computer called ServerA and I want to have it send a print job to a printer queue on a computer called WorkstationK , is there a way to do that without networking the printer attached to WorkstationK ?

NOTE:
I almost asked this over on SuperUser, but I am wanting to do this from a ASP.NET service, so solutions like "copy the file to the workstation...." does not work.

Use Case:
In case it matters, this is what I am wanting to do, I have an application that will take some input. That input will be sent to the server ( ServerA ). As a result of that input, I need to send a print job to a given computer, WorkStationK for example. But it could be one of about 100+ computers.

So I don't want to setup all those all of those printers as "Network" printers. Also, I don't want to install/create apps on/for the workstations (it is an easy app to write and I will do it if I have to, but I am hoping for a no-deploy solution)

What you are trying to do is probably not possible because if you think about it, it would be a real issue in terms of security/abuse. If a website could print stuff without confirmation on a local pc, this would be some serious madness. And for that reason there do not exist any interfaces to do this. If they do I would be astonished by it and please correct me!

Solutions that come to my mind:

  • Just produce the page to be printed and let the user click "Print". Doesn't require installation and is probably not too much for the user.
  • Write a small daemon service/application to be able to send the print-job to the computer that currently is connected to the service and the daemon handles the adding to the print queue.
  • Deploy your service as something small and easy like a ClickOnce-App that should already suffice to be able to do this task. The user himself would be easily able to install it without privileges and one click. And it would even update itself so changes would be really easy to do/comparable to a web-app.

What you prefer is up to you but as stated above I don't think it is possible to do it completely remote.

Another possibility I didn't think through and certainly don't have enough experience with it, is something like Google Cloud Print or other services like this. Maybe adding this your company could be a pretty comfortable solution that would pay off in a greater perspective.

I understand you have the following architecture:

  • Server with WebApp
  • a large number of workstations, each connected to a close-by printer

Use Case

As a use case I understand:

  • The user uses a WebApp through the browser and at some point clicks a button that reads print or alike
  • The server has to render the document to be printed
  • The document is supposed to be printed from the workstation on the close-by printer

I see two possible options.

Solution 1

The idea is that the button print not only sends the request to the server app but also generates the file (let's say in pdf format) and sends it back to the client's browser. If this is done within the Request by streaming the pdf file out as the response to the request, the browser would download the pdf file automatically.

The server code could look something like this (:

private void CreateImageAndReply(Src source)
{
    // render the output file using GhostScript or alike to 
    // a subdirectory that is accessible via http
    [..]
    // 
    Response.Redirect(DownloadFileUrl);
}

The subdirectory to render the file to from the WebApp has to be added through the IIS Manager via add virtual directory (see 截图 ) to enable the access from the browser. The user would be left with the duty to open the file and print it through the system's print dialog.

Development Tasks

  • Implement the rendering and Redirect
  • Test against all used browsers

Deployment Tasks

  • none

Solution 2

The idea here is that the server can store the document in a directory accessible to this very client.

Once the print file is written, a job running on each and every workstation sees the new file and prints it (ie through the Print command inside a console program or a batch file or a PowerShell file).

To manage the 100+ "PrintBoxes" you could use the ComputerName as a folder name from inside the task running on the Workstation side and inside the WebApp on the server side as well (ie by using Environment.MachineName ). The WebApp could eg render the pdf file to c:\\Printboxes\\Desktop123\\print0310.pdf. The client-side task could be started through the TaskManager eg at the beginning of the work day and poll the content of a mounted network directory, eg n:\\Printboxes*.pdf; this local program would send any discovered file via the print command to the local printer and delete the file thereafter. It could also write a receipt file back to the directory (ie print0310.receipt) which would be accessible to the app WebApp on the server ... I think you get the idea.

As an alternative to the mounted network drive you might consider using sth like Dropbox on all the above mentioned machines (server and workstations) to synchronize the files back and forth in a secured way. This way, only the Dropbox-User (could be a free account; same user on the server and all the clients, no interaction of the user necessary).

Development Tasks

  • Writing the rendering on the server plus the Redirect as mentioned above
  • Writing a ConsoleApp that can be deployed to every client

Deployment Tasks

  • Install/Copy cmd executable (small C# program)
  • Schedule a task to run it at system start or user log-on
  • Install Dropbox (with user)

Hope it helps!

I'm sure you've googled a lot, but just for the sake of adding info (since I can't comment yet :()

I think you will have to find a way to generate a SPL file, send the SPL file to the workstation, and prompt the workstation to print it.

To generate a SPL File: You might check this out... I know you don't want to install anything on the workstations, but this might help you grab the a SPL file of the print job.

http://www.lvbprint.de/html/splviewer1.html

Also, for some printers there are settings to capture the SPL file of a print job. You might be able to be clever with a PDF printer (or something) on the server to capture the SPL file of a print that way?

To send/print a SPL File:

Sending should be easy enough, but I didn't see any super easy ways to print from a SPL file. There's this...

https://support.microsoft.com/en-us/kb/179774

...but it requires a lot of intervention at the workstation level which may be difficult/impossible. I don't know if simply dropping the SPL file directly into the default directory for the printer spool is enough to make it print.

Still looking...best of luck.

How would ServerA know which printer of WorkstationN use, if there is one ?

If these printer are network printer, you should be able to send the job directly to them over network. If they are "smart, last-gen printer" you could even send the document to print by email as attached files using the constructor stuff instead of creating your own app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM