How to get document in print queue - c#

Is there any way in C# to get the documents sent to the printer from another program and use those documents again for something else?
I want to build an application which can get invoice sent to the printer by some point of sale system and gives opportunity to send that invoice to customer's email.

Well, you could print to the XPS printer and have it create a file. Then, let the system print the XPS file using the standard application. This may or may not work depending on some factors:
Is there XPS support on the system?
Did the user change the default application that handles XPS files? Maybe printing is no longer possible...
Is XPS a file format you want to send to the users?
etc.
That said, of course you could do the same thing with PDF, but you'd have to have access to an application that can actually print PDF. It has been asked multiple times here how to "send PDF bytes" to a printer - you can't. There are solutions, but in the end you have to answer this question for yourself:
Is it really worth the hassle or isn't it just easier to print the document and then create it again as PDF (for examples) to send to the user?

Related

Can Adobe Reader process JDF job tickets?

I'm trying to generate a PDF that can be viewed interactively in Adobe Reader, but also, upon printing, selects different paper trays based on the page. (Some pages are supposed to use stationery, whereas other must not.)
PDF itself apparently doesn't support this form of metadata by design (as discussed e.g. here), but apparently, JDF is an appropriate format, and can be embedded as XML in the PDF.
What's less clear to me is if Adobe Reader does anything useful with that metadata: if a PDF with embedded JDF information is printed, does it parse the JDF and choose paper trays? Can I use PDF portfolios for this purpose instead?
My goal is to both let the user view the PDF in Adobe Reader interactively, and, upon printing, automatically selecting different paper trays.
(The far less convenient alternative would be to write a custom app to do the printing.)
You are right, PDF describes the artwork while the JDF describes the metadata about print. However, JDF is targeted to industrial printing systems rather than for desktop printers. As far as I know does Adobe Acrobat Reader not support this kind of feature based on a JDF.
In order to control the different paper trays of your printer, you may setup your printer several times - one for each tray and switch the flag "default printer" in the background programmatically.
Another idea could be to use the Acrobat Reader only for viewing purposes and using the command line for printing.
There are concepts of how to put metadata into the PDF directly (see: https://confluence.cip4.org/display/PUB/PDF+Intent), but it could take a while until this specification is gonna to be implemented.

Monitor print queue and merge jobs into one using .Net

I have an automated app which creates a set of outputs and sends them separately to the printer. Each page of the job is being sent as a separate print job which is undesirable, as it makes it almost impossible to use a PDF printer and convert create a single PDF file out of them.
I was wondering if there is a way to write a simple console or windows program that would receive these print jobs, merge them together and send the whole thing as one job to another printer. Is there anyway to accomplish that?
There are three ways I see to accomplish this.
The first would be to modify the original program. Have it drop PDFs off in a directory that is monitored by another program to do the combining.
The second is to install a PDF print driver whose output is a file on the file system. Every print job would output as a separate file. Your program would then monitor that and combine as necessary
The third way is to write your own print driver which takes the jobs and combines them.
However all of these "solutions" require you to be able to identify which page goes with which document and in what position of that document. Honestly, without far more information, the best route would be to modify the originating program to just do what you want.
It is not possible to merge print jobs, after they have been added to the queue.
What application is producing these documents?
What output format does it produce?
What is your intended output format and destination?
(printer/email/something else?)

C# RAW Printing

I have a requirement whereby I need to be able to send an image to a printer.
The problem I have is that the target printer (and type) is not necessarily know at the time of printing and we could be sending to a zebra/intermec label printer or a standard HP office jet.
One further complication is that we have hundreds of printers to manage.
I do not want to have to install hundreds or printers and have to manually install a new printer every time we add one to the network. We maintain a list of IP Addresses and ports.
I have been considering installing a default printer (zebra, intermec, officejet) for each of the printer types.
When printing (using PrintDocument) I can send a print to the default printer of that type but mark the output as "PrintToFile". I believe this would then give me the raw print data (PCL?).
My thought process is that I should then be able to simply send the raw data to the printer? Unfortunately this does not seem to work and the raw text is simply printed.
Can anybody offer some advice/help?
Thanks in advance.
Raw files will not be sharper than the JPG files on printing, for me the best solution is to convert the RAW file in JPG

How to merge different document types and show as stack in .NET application

Suppose in .NET (don't care what language) I want to show a user a PDF, Word and Excel file together. I am trying to replicate a document process where a user might have a PDF file and he would like to attach a WORD file and an Excel file let's say to make a stack of documents (that I would save in some directory). Then he would like to click on a button and see a stack of these documents in 1 application of some sort.
How can I display the stack of documents WITHOUT first opening WORD, then openinig EXCEL and then openining ADOBE ACROBAT - this would be really annoying for the user. I would like one unified application or some idea to mimic one in .NET that can just show all 3 documents as if they were printed one after the other on paper. (I hope I am explaining this clearly)
The only thing I can think of to do this would be to leverage some sort of PDF conversion process to create one PDF file containing all three of these documents in "printed" (page-by-page) form, and then show that. The one application I can think of that could show all of these files is a web browser with appropriate Office and Acrobat viewer plugins, and you might find it difficult to leverage that, as browser preference and other user OS settings can cause various strategies for application launching to fail.
I would convert the documents in PDF and develop a pdf viewer inside your application.
I would use a ready made library for that, don't reinvent the wheel.
For example: http://www.quickpdflibrary.com/products/quickpdf/index.php

Save All Print Jobs As PDF

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.
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.
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#
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]
Issue two print commands... one to the paper printer, one to the PDF printer.

Categories

Resources