printer driver type application - c#

I am working on a application which requires me to create a printer type driver, which offers to decrease the quality of document, and then prints the document.
Where document can be anything like image, word, pdf. And this application should be listed as new printer in the documents printers menu.
What I was thinking to create an application that will be installed as printer driver, and when this printer is selected for print then this application consider print documents as image and decrease the image quality based on user input. then these can be copied into new pdf and then print this newly created pdf silently using default printer drivers.
Can anyone tell me if I am thinking on the right track, and if I am thinking on right then please help me out in this, as I have no idea how to do this stuff.
I am using C# and .NET for creating this application.
thanks in advance

It's a good approach but it's not possible to create a printer driver in C# and .NET. You will need the Windows Driver Kit and C/C++.

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.

Create an XPS DC in C# with a given filename to be delivered to a printing function

I am building a C# application that uses a DLL for print.
The print function receives a printer device context (or 0 for default).
If the Microsoft XPS Document Writer is the default printer, running the print function
with 0, results in a pop-up that ask the user to enter a path and filename.
I wish to give the filename myself (no popup).
I've surfed the net and came up with some information regarding printing XPS without user intervention (fyuan blog posts) but most of it revolved around adding a new printer or using WPF.
I am looking for info on how to create a DC that works with the "Microsoft XPS Document Writer"
but also to have a DOCINFO (lpszOutput) with the filename already given.
Any help would be appreciated.
You will delete filters in pipeline xml and also related dll's in inf file. But yet, as I did, i guess you will face problem of printing canvas (graphics). I wasn't able to convert / transform this canvas to glyphs to get the contents of it.
If you had further issues, let me know
Kind Regards

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.

Printing a PDF from a Windows service

With C#, how can I print a PDF document (without any dialog boxes in the background) to an indicated printer?
I have used the following PDF library in the past to perform batch printing of PDF documents from a C# Windows Service.
http://www.quickpdflibrary.com/
It's a pretty decent library and if I remember correctly it only took a few lines of code to print the document. It worked very well and saved me a consider amount of time.
Also, the recommended link that discusses using DDE to launch a desktop application on a server to perform the printing is a bad idea. Adobe Reader probably doesn't support this and since it is a desktop application running in a windowless session you may run into problems with message boxes and dialog boxes. That solution just doesn't scale in my humble opinion.
here we go
Disclaimer: I work for Atalasoft
If you don't want to depend on Acrobat being on the server, you need to rasterize the PDF pages yourself and send them to the printer using the normal .NET printing API. We have a product that can rasterize PDF that uses the Foxit engine underneath. It deploys as a normal .NET assembly and doesn't require any other software to be installed.

Categories