How do I write a print job image to disk? - c#

When I print any document with my computer I want the printed page to be saved on my computer as for example a bmp or jpg file and printed to a piece of paper at the same time. I don't know if it is possible to extract this information from a printer or if it is possible to make a virtual printer and use it as "pass through" and get the image from the virtual printer and send it to the real printer afterwards.
OS: Windows XP.

The Win2PDF virtual printer can create a PDF and print it to a paper printer at the same time. To do this, set your real printer as the Windows default printer, print to the Win2PDF printer, and select the "print file" option in the file save window. After the PDF file is created, it is automatically printed to your real printer.

Related

Windows driver only save binary file

I need own printer on Windows. I just need when I from any application (adobe reader, IE etc.) have open html page, or PDF when I click on file, print choose printer and this printer only take original input data as binary and just save to file disk.
I try to solve this problem with universla PS drivers for windows, but convert file from ps back to PDF or XPS can destroy PDF. Do you know some drivers or example?
Windows printer drivers according to documentation on MSDN can be only in C++. So I like avoid to write driver by own. I have my own port which can take document from printer and save them. But I still need driver which just take input after Ctrl+P arise and send to my port or save to disk.

Ghostscript.NET can't print with selected printer name

I want to print a pdf file with selected printer name via Ghostscript.NET. This application is actually a wrapper of CefSharp browser. When user click on a download button, it download and print out with selected printer directly.
You can see the screenshot above, I pass the printer name thru URL query string. Also, I have set the option -dNOPAUSE & -dNOPROMPT. But why it still come out a print window, and the default selected printer is not what I have set?
Any idea what's going wrong here?
EDIT: Mar 4, 2016 11:31am
For ghostscript in command line, it will be like
"C:\Program Files (x86)\gs\gs9.18\bin\gswin32c.exe"^
-empty^
-dPrinted^
-dBATCH^
-dNOPAUSE^
-dNOPROMPT^
-sFONTPATH=C:\Windows\Fonts^
-dNOSAFER^
-dNumCopies=1^
-sDEVICE=mswinpr2^
-sOutputFile="%printer%Brother MFC-295CN Printer"^
-f C:\Users\Dell\AppData\Local\Temp\file-tmp.pdf
but then it still show the print prompt.
Add -dQueryUser=3 to your command line to print directly to the default printer using that printer's default settings.
If the printer you are printing ot is not the Windows default printer, (on this system) then you must specify the printer in the print dialog. This is because there are 2 disconnected entities.
1) The printer you send the data to.
2) The creation of data in the correct format.
The mswinpr2 device uses the Windows print system to take the rendered output from Ghostscript and convert it into whatever the printer understands (PostScript, HP-PCL, Epson ESC/P etc, etc). It then sends that data to the named printer. NB this is why the driver for that printer must be available locally.
However, the mswinpr2 device doesn't know which printer device driver corresponds to a given named printer of the form "%printer%Name", you have to tell it that. If the named printer is the windows default printer then you can use -dQueryUser=3 to say so, otherwise you need to present the printer dialog so that the user can select the correct printer and that's what mswinpr2 uses to create the data that it then sends to the printer.
I believe that its perfectly possible to get this wrong! If you select a PostScript printer in the printer dialog, but then set -sOuputFile=%printer%HP-PCL printer" the combination will send output formatted as PostScript to a printer which expects PCL, the result in that case will be reams of garbage printout.
You need to exercise caution with the use of this device, which is why the default behaviour is to make you select the printer from the list of available printers.

Emulate a printer in pc

I have made an desktop application using C# to make ID card .And i am required to add functionality of printing an ID card .Basically i just make an image in a win form which will be eventually printed using.
But as i have no printer,i can't test my code to see if it prints something.
Is there any emulator or software that emulates a printer in windows,so that i cant test my application?
This is a sample what i need to print.It wiil be in a win form.
And another thing. How can i maintain size of the id card while printing. Say id card size should be in 2inch * 3.5inch. How can i make sure it will print same size?
You can use the Microsoft XPS printer driver that ships with Windows (since Vista, but available for Windows XP)
The XPS Document Writer allows you to create .xps files using any
program that you can print from in Windows. Print to the XPS Document
Writer when you want to create, send, and share or publish documents
that you do not want other people to modify, or when you want to print
a document or display it online exactly as it appears on your screen.
It's also a good idea to create an XPS document for files that contain
graphics or illustrations that might otherwise display differently in
print than online or on computers with different monitors.
Once you click OK, you're prompted for the file path to save it to.
Try print to PDF file to check that Your application works. For example You can use "PDF Creator" under Windows OS's. It is the easiest way.

Save and Get network printer options

My goal is to send a PDF to a printer with specific sheet feeder, that is configured a first time by print option dialog (or just a form with network printer, tray, and margin).
I've seek about PrintDocument, PrintDialog (from System.Windows.Forms) and PrinterSettings
I can show network printer, save the selected network printer and I can use this with PrinterSettings.PrinterName but my issue is on tray's choice. I have no option to select this and customer that use my application can take every printer that exists.
So how I can show all the tray of printer selected, save it and use it to print ?
Does this link:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersource.aspx
contains useful information?

Create virtual 'shredder' printer

I need to create a virtual printer that 'shreds'
Basically here is my problem. I have a software program that needs to 'print' a file before it will save it. I want to be able to print to my shredder so that it saves the document, but I don't actually want the document printed. So I need to print to a program that securely deletes the document and shows as a driver in Windows.
How would I go about doing this in C# of VB.Net?
No need to write code for this just print to nul. This has worked since DOS. Just create a new printer, printing to a local port, and put nul in there for the port name.
http://www.markmmanning.com/blog/2009/01/creating-fake-printer-devnull-for.html

Categories