Sending PDF Byte Array to Print - c#

I'm trying to get my web app to send a PDF document to a networked printer but, all of the examples I've seen all require a physical file to already exist, which doesn't work for what I need.
I have a service that given an id, returns an object where one of the properties is a byte array of the PDF document.
How do I send this to a named network printer?
I have tried evoPDF's PDFPrint, but it is rasterizes the PDF document before sending the content to the printer, which is inflating a 14KB file to over 40MB which seems ridiculous.
The evoPDF support said nothing can be done to change that, so I need to find an alternative.
The web app would be sending hundreds of 3/4 page documents at a time, and waiting for the printer to spool upwards of 50MB for each one is not acceptable.
Is there a better way?

You can try with this library http://www.terminalworks.com/pdf-print-net.
It should support printing from byte array.

Related

PDF TO DOCX(PDF memorystream to DOCX memorystrem)... Stream to stream conversion

I will be getting PDF file (PDF file might contain hyperlink or image etc.... ) data in memorystream format in my server(I will not get PDF file path.. I will get only file data in memorystream)... I need to convert this memory stream to DOCX( DOCX data is also in Memorystream format)...
I have used aspose dlls for the above scenario.. But for larger PDF files its giving Array Index Out Of Bounds Exception... and some times process is getting stuck at doc.save...
I have posted my query in Aspose blog aswell... they are also getting same issue in there end
Refer this link...
I have checked in the following sites .. but still no luck..
link 1
link 2
Is there any solution is available for scenario....
In the limited duration before a ASP.NET script times out, you are trying to convert very big PDFs. This is designed to fail. Do the conversion in a Windows service process. Use ASP.NET only to receive the documents for conversion. Make the service mail the converted documents.

How to get document in print queue

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?

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 send raw data to a printer by using Visual C# .NET and print a pdf file

I'm reading a pdf file attachment into memory and trying to send it to the printer.
I seem to be having an issue with the type of the document.
I'm creating an instance of DOCINFOA and I've been experimenting with the values for the data type parameter as described in this posting:
How to reprint a spool file using XPS printer?
However I'm not getting a print. The document appears on the print queue but then just disappears. I've tried all of the possibilities for data type, all those with RAW appear on the queue but nothing is ever printed.
I get a print using TEXT but its just nonsense, and all of the rest do nothing at all.
I'd like to know what the data type should be in order to print a pdf.
If I don't use the winapi functions and instead write the document to file and open it programatically using acrobt32, I get the print that I expect, but we want to avoid writing to disk.
I'm using code gleaned from this post:
http://support.microsoft.com/kb/322091/en-gb

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