5

The Goal

The company I work for currently uses a black box shipping system. Each morning our shipping manager prints out shipping tickets for his drivers. Using C#, I would like to save a copy of each ticket printed as a PDF. The action of saving to a PDF should be done behind the scenes.

Note: The PDF copy would be in addition to the hard copy, however, I would like to generate the PDF copy when the hard copy is printed (or directly after if I can use the saved print job).

End Result: The manager prints a hard copy and a PDF gets saved to an archive folder without any interaction from the manager.

What I've Tried

I've instructed the printer to "Keep printed documents" after printing. This leaves a .shd and a .spl file in the print spool folder. I've experimented with the PrintDocument class, but I can find no way to instruct a job to reprint (to a PDF driver) using a completed print job.

Question

Is what I'm trying to accomplish possible?

Further Clarification:

In case it wasn't clear, I do not want the manager to print the document a second time to a PDF print driver. On average he must print 60 tickets each morning before he can send his drivers out. I don't want to increase that number to 120 AND force him to type in the file names.

Additionally, the "black box" shipping system includes other modules that run other portions of our manufacturing plant - changing software is not an option.

James Hill
  • 60,353
  • 20
  • 145
  • 161
  • Can you tell the manager to use a different printer? – Daniel Hilgarth Dec 01 '11 at 16:34
  • @DanielHilgarth, I'm not sure how that would help? I want him to be able to continue to print out a hard copy for his drivers. The PDF would be in addition to the hard copy. – James Hill Dec 01 '11 at 16:36
  • I understand that. You are asking if what you want to achieve is possible. If you can use a different printer, it is possible: Write (or install) a printer driver that forwards the print job to the printer and additionally to a PDF printer. But I am not sure that is the easiest way :) – Daniel Hilgarth Dec 01 '11 at 16:39
  • @James Hill : Can the manager print using another printer installed on the computer? (instead of default printer) – Mahdi Ghiasi Dec 01 '11 at 16:39
  • @Mahdi, the manager can print to any printer he wants. – James Hill Dec 01 '11 at 16:40
  • Assuming you have access to the data (given you're trying software approach) why not archive to a database for regeneration/indexing? – Brad Christie Dec 01 '11 at 16:42
  • @JamesHill: I assume you can't change the software the manager uses to print the tickets? Maybe you should state that more explicit in your question than just saying you are using a "black box shipping system". – Daniel Hilgarth Dec 01 '11 at 16:43
  • @DanielHilgarth, I wish! The software runs our entire manufacturing plant. – James Hill Dec 01 '11 at 16:43
  • 1
    @JamesHill: As a follow up to my comment with the printer driver, have a look at this: http://www.frogmorecs.com/printdistributor. Especially interesting: The screenshot "Virtual printers". Have a look at the second printer. It is named "Print and save"... The link comes from [here](http://superuser.com/questions/126549/print-to-2-printer-by-default), I have no experience with this tool myself. – Daniel Hilgarth Dec 01 '11 at 16:46
  • @DanielHilgarth, This solution seems to meet my requirements best. Can you please post as an answer so I can accept. – James Hill Dec 01 '11 at 17:09

4 Answers4

3

I suggest you go with an existing solution to problems like this: Use a software that can install virtual printers that print the document on the printers you want. One such software is PrintDistributor. I don't have any experience with this software but the screenshot named "Virtual Printers" looks promising: The second printer is named "Print and save".

There is other software like this, see here.

Community
  • 1
  • 1
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
2

According to your goal that you don't want to force him to enter file names, You should do this:

Use a PDF Printer software that provides automatic file naming, like these:

PDF Desk

Cute PDF

And tell the manager to print tickets just with that PDF Printer.

Then, write a c# or vb.net application. use FileSystemWatcher to detect if a new file is created in PDFs directory. and when a new PDF is created, print it.

Here are some tutorials that explains how to Print a PDF file in c#:

Print existing PDF (or other files) in C#

Printing PDF documents in C#

Community
  • 1
  • 1
Mahdi Ghiasi
  • 14,873
  • 19
  • 71
  • 119
1

Trapping things being sent to the printer can be very tricky.

A simpler way would be to set up a 'pdf printer' using a piece of software such as: http://www.bullzip.com/products/pdf/info.php

Configure this to output to a specific directory, and then write a windows service to monitor the directory and automatically send PDF files to the physical printer and archive the file off to a network folder.

[and remove the printer driver from his PC so he can't bypass your new system]

simon831
  • 5,166
  • 7
  • 33
  • 50
  • +1. Tell him to print to PDF ALWAYS and then YOU can re-print the PDFs to the physical printer. Exactly what I was thinking. – Steve Dec 01 '11 at 16:58
0

Issue two print commands... one to the paper printer, one to the PDF printer.

Jared Peless
  • 1,120
  • 9
  • 11