How can I invoke an exe from Printer Driver? - driver

I have created a V4 Printer Driver. I want to invoke another application(.exe)from print driver with print stream as parameter to the application.

Related

Print job shows in network printer queue, but spooler deletes it and it does not print

We have a Windows 10 machine that can print from applications like MS Word. (Print server 2019) However, when we try to send a print job to the printer from another in-house application, the print job gets deleted by the spooler.
You can see the print job in the printer queue on the originating machine, you can see it in the queue on the print server, but then that's where it stops. It does not get to the status of "Printing job ". Instead the job gets deleted then throws an error (ox2) when trying to delete the file that is already gone.
We tried
changing the printer protocol from LPR to RAW
printing directly to the printer instead of through the print server
sharing the printer from the client machine and printing to that
turning on the EMF Spool option
updating the drivers on the client machine and the print server

Delphi Network Printer Access Path

I have my original question posted here:
Delphi Printer Access
Now we need to handle one more case of network printer with specific IP say xx.xx.x.x .
How Do we access Network printer from Delphi for Rewrite function?
I did sample app with this code and it works for all printers:
AssignPrn(lOutputFile);
Rewrite(lOutputFile);
for liIndex := 0 to lsLines.Count-1 do
Writeln(lOutputFile, lsLines[liIndex]);
CloseFile(lOutputFile);
On click of f7 on CloseFile(lOutputFile); in sample app, control goes nowhere and printing works.
When I integrated my code in the main application
On click of f7 on CloseFile(lOutputFile) it goes got o Devexpress files and its not printing.
kindly suggest.
Windows can access network printers. See the documentation.
Once the printer is installed, your application can access that printer just like any other [local] printer.
Use a fully qualified function name: System.CloseFile(lOutputFile);

Starting external .exe when XPS Writer has finished

I wrote a XPS Driver using the XPS Driver Sample XPS Driver Sample
What I want to do now is, that I need to start an external programm when the XPS Driver has finished its job and the document is ready.
So the user should click "print with... -> myCustomXPSDriver..." and after the xps document is ready a program should start.
My problem is, that I can't get the job status and dont know how to get the information that the document is ready without watching the directory.
I need the driver for Windows 10, so I can't use a port monitor.
Any examples and/or ideas which is the right way to do this?
-Printer Extension?
-Universal Windows Application?
-BIDI Extension?
Thank you so much for your time and help!

Change line printer port to be used by gw-basic program

How to use lpt2 as the "line printer" in a gw-basic program. The goal is to change the printer port to lpt2 so i can use the "net use" command to redirect the printer output to a network printer. I can redirect lpt1 to the network printer but have to disable the hardware printer in device manager. However, I get the error printer is offline message.
All this is necessary to get data from the old program data files. I plan to reprint, OCR and import into new software.
You can use the emulator PC-BASIC to run your GW-BASIC program, read its data files and connect it to any printer. Point PC-BASIC to the printer by running it from the command line as
pcbasic --lpt1:PRINTER:MyNetworkPrinterName --print-trigger=page
where you replace MyNetworkPrinterName with the name of your printer in the operating system. If you want all output collected in a single print batch, replace --print-trigger=page with --print-trigger=close.
However, you mention that your final aim is to import the data into another program. A better solution, avoiding the error-prone and labour-intensive scanning and OCR step, might be to let PC-BASIC print to a file directly:
pcbasic --lpt1:FILE:MyOutputFile.txt
which will send the print output to a UTF-8 text file.

Need Help in Building Printer Driver

I need some help in building printer driver. The printer connects to system via serial port. I just need to grab the data that application sends to the printer, compress it (its a custom routine) and send it to printer.
I do not have any experience in developing drivers. I have all the tools, SDK, DDK. If someone could point out some link to a sample driver (that could just write to flat file instead of sending to printer) that would be great.
The driver has to run on windows NT.
So basically i am looking for some sample printer driver, the DDK (with the name of winprint) has one but when i compile and link it, it generates dll file instead of sys.
Please not once again that the WDK wont work as this driver would be running on NT.
You should use the Win NT DDK. It would have sample files. Also in Windows NT, the printer driver files are actually .dll files and not .sys files. Printer drivers are a different category of drivers in Win NT and need to be installed using the Add Printer Wizard and in a package form with an INF file.
If you already have the Win NT DDK, you could use the sample TTY driver that is present. I believe this is available in %DDKROOT%\Src\Print\Mini\Txtonly.
This article talks more about some update to this driver - http://support.microsoft.com/kb/289108
Once you are able to install and run this driver, you should be able to see the main code and add in your own code to get the incoming data and stream it to a file.
Hope this helps. If so, +1 :)
You don't need to modify code to get a driver that can write to a flat file.
A Windows printer driver can be connected to a variety of ports. In particular you can create a Local Port that is actually connected to a file. On the printer's Ports tab, click [Add Port] and then select Local Port and click [New Port]. In the 'Enter port name' edit-text control type the path of the file you want to be filled with PDL data. Then every time you print subsequently, the PDL from the driver will be written to the file associated with the new port, overwriting its previous contents.

Resources