Starting external .exe when XPS Writer has finished - printing

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!

Related

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);

Process Monitor Troubleshooting custom print driver, print spooler

Our users upgraded from Windows 7 to 10.
When they try to print using a custom print driver they get this error
The document Print Document, owned by User, failed to print on printer TEST-PRINT. Try to print the document again, or restart the print spooler.
Data type: NT EMF 1.008. Size of the spool file in bytes: 628788. Number of bytes printed: 12900. Total number of pages in the document: 6. Number of pages printed: 0.
Client computer: Devcomp. Win32 error code returned by the print processor: 2147500037. Unspecified error
Some of my observations: Internally we cannot reproduce this error internally. I have a windows 10 surface and also tried on a windows 8 machine. Our support tried it here too.
The customer can reproduce the issue without. The issue happens for some documents on some workstations. The PDF is generated from a 3rd party application for tellers. The customer saves the pdf from this signature desktop application to a PDF and uses our print driver to print to the our application.
Our print driver converts the file to PCL and sends it to the subscriber for further processing.
I can provide more info if needed regarding print driver. First of is it a problem with the print driver?
All the users who upgraded from windows 7 to a windows 10 laptop can see the issue happening. There are some windows 10 workstations that print just fine. Could it be something with the group policy or some registry settings. If I were to compare the registry or policies on the workstation that prints and the one that fails what would be the settings I need to look for? The customer's IT says that there is no difference between the two workstations except that it’s the production workstation that fails. Typical response nothing different but it doesn't work.
We also tried to disable “render print jobs on the client workstation” but this didn’t seem to make difference. I am happy to try any suggestions you’ll have.
I am looking for ideas of what kind of research and where should I start troubleshooting.
I won't be troubled if anyone chooses to vote the question down that I didn't do any research since I really don't know where to start. I am a .NET developer not a windows driver expert or systems admin.
Process Monitor Good File. The file gets created.
Create file success, create file name not found and finally create file succcess
Bad File: Create file success, create file name not found. The last create file is not called by the print.exe driver.
This solved my problem. Thanks Papercut!.
https://www.papercut.com/kb/Main/FixingPrintSpoolerCrashes
https://www.papercut.com/kb/Main/EnableAdvancedPrintingFeatures

XPSDrv Sample Entry Point / Filters Squence

Finally, I managed to build XPSDrv Sample project successfully . But still there is a problem .
I need to execute a function ( to start an exe file ) after the xps file has been sent to the printer (in my case to local port). So , where and how can I add the function ?
And regarding the filters , how would I know the sequence in which the filters executed .
I really need a help in this matter because I am a beginner in Windows Driver Development , specially in Printer Drivers ...
Any Idea is highly appreciated.
Thanks in Advance
Which filters are included, and the order in which they execute, is controlled by the PipelineConfig.xml.
I'm not sure that launching an external executable after the document has cleared the pipeline is a particularly good idea, but if you must do so, you will need to add that functionality to the last filter in the pipeline.

How to use a host-based USB printer from WinCE

I'm testing an HP LaserJet printer with WinCE7, it's a host-based (not PCL) printer.
When it's plugged into the USB port of WinCE, the USBPRN.dll is loaded but PCL.dll is not loaded which is as expected.
I included wordpad in WinCE and tried to print from wordpad, but there is a error message box saying no printer babah. Printer setting dialog box is not displayed.
Then I use CreateFile/WriteFile/CloseHandle APIs and try to send some ASCII string to the LPT1 port.
The return handles are valid but nothing happened on the printer. According to the debug log, I see something wrong inside WriteFile although the return value is valid.
Then I'm stuck.
I have several other options to try:
Use OpenPrinter/StartDocPrinter/WritePrinter API set. But I'm not
sure if they are different from CreateFile/WriteFile/CloseHandle.
Check to see if there's any open sourced driver for the printer in
Linux world, then I can see what's the data & format I should send
to the printer. But I don't know Linux at all. I'm not sure what
part is different from Windows to Linux or what part is same to
different OS.
Anyone can point out any information about how to implement a
host-based printer driver? Just introduction about the architecture
is also welcome. For example, is there anything related to the
device context (DC) or bitmap or anything else.
I'd like to see any comment on which direction I should go.
Thanks,
Fei

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