Windows driver only save binary file - c#

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.

Related

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.

Print to File Programmatically using Adobe Acrobat

In the advanced print settings inside adobe acrobat reader, I have noticed that there is a print to file option. I am currently developing a library of functions in vb.net that prints files of various formats to print language files (postscript). I can't seem to find however a way to access this functionality programmatically, is there a way to do this without using a third party tool as I need to try and avoid using external libraries if at all possible.
You can use the PrintDocument class to print to a PostScript printer on the FILE: port. PostScript print drivers are provided with Windows by default. An example is HP LaserJet 2800 PS, which is provided with Server 2008. Generally if it has PS in the name the printer will be able to print to file.
https://learn.microsoft.com/en-us/dotnet/api/system.drawing.printing.printersettings.printtofile
...
printDocument1.PrinterSettings.PrintToFile = true
printDocument1.PrinterSettings.PrintFileName = "c:\temp\test.ps"
printDocument1.Print()

Print a PDF server side from ASP.NET

I need to take a PDF file url, send it as a parameter to a web service that will print it on a network printer. It has to be done server side without any user interaction.
Do you know some libraries that we can use to acheive that ? We look at different options like iTextSharp but it looks like there's no way to print from that library.
Thanks.
If you can download the file and save it as a PDF and have Acrobat Reader installed you can use a command line to print it (shell it).
http://www.robvanderwoude.com/commandlineswitches.php#Acrobat
Print a PDF file silently:
AcroRd32.exe /N /T PdfFile PrinterName [ PrinterDriver [ PrinterPort ] ]
It would be nice to know what commercial component you used...
I had to something like that, but using PCL. We used winspool.drv to open the printer, start a document then a page, write out the bytes, then end the page & document and close the printer. We installed PCL drivers for the printer on the local machine to print to a network printer.
You might be able to do something like that with Postscript drivers. A quick test would be to to a binary copy of a PDF to the printer using the command prompt and the /B switch on copy. I think you specify the PDF and the printers network share as source/destination. Use a small PDF to avoid getting a ream of random characters in case it doesn't work.
We'll finally use a commercial component that does all this by itself.
Thanks for your help.

Program/algorithm that creates a .PRN file of any file format for a specific printer! Please help!

I need an algorithm that converts any file format to its .PRN file equivalent which will be compatible for a specific printer (for example, only in CANON printers).
Or I need a source code or way to know how printer drivers work. Printer drivers are the one who specifies or creates the .PRN file of any type. So please help me. Thanks!
Since you said, from any format to .prn format, I am taking two cases here assuming Windows environment:
Let's say your source is MS_WORD (.doc) file. If you have the appopriate printer installed, you can easily get the .prn file, by opening the file in MS-WORD and doing print using the appropriate printer. However, before this, set the port to "File" in Control Panel for the particular driver.
However assuming you have a file in some xyz format, for which there is no rendering application needed, you may have to identify a converter on a case to case basis probably
Consider dowloading the windows driver kit (WDK), it has free printer driver sample code,
you can find the full list of sample code it has here. Also, you can look at the printer driver docs here

Looking for a Pdf Printer to use in a Docx -> Pdf Conversion Service

I'm not sure if this is possible but as I was looking for a way to convert docx -> pdf serverside (Aspose is a bit expensive), I wondered if I could do this by printing my document to a Pdf Printer.
Altho, I would need a decent one then, as it shouldn't show dialogs when trying to print ofc.
Does anyone know if:
This is possible
There exists such a printer which can be easily used in a WCF Service
Thanks
Try pdfcreator.
PDFCreator is a free tool to create PDF files from nearly any Windows application.
Key Features:
Create PDFs from any program that is able to print
...
Terminal Server: PDFCreator also runs on Terminal Servers without problems
If you can read DOCX content and print from your WCF service, the pdfcreator printer driver will generate PDF from anything.

Categories