Allowing input tray selection with PCL printing in JDE
It is a known issue that you cannot do tray selecting in JDE when your printers are PCL... Or can you???
Introduction
PCL printing is different to PS, where PCL is all embedded in the file that is sent to the printer, there are no “command line” options as such. This is why JDE does not give the same flexibility in the PCL printing options as they do for PS.
Dumpbin to find the which DLL has the function you want, and include files.
I’m using the above to find functions with PCL in their text and locating their address:
950 3B5 00195260 _SetupClientSecurityAPI@4
951 3B6 00195B40 _SetupClientSecuritySilentAPI@4
1131 46A 0020C020 _convertPDFToPCL@2524
2164 868 0020C060 _prtFilter_ConvertToPCL@20
So the function that I want has 5 parameters, it’s the last one with @20. @4 means one parameter, @8 two etc.
I can find the include files to see the parameters, but that is not important.
KRNL_RTN( int ) JDEWINAPI prtFilter_ConvertToPCL ( HUSER hUser,
JCHAR* szInPDF,
JCHAR* szOutLP,
PPRT_PRINTER_INFO pPRTPrinterInfo,
BOOL OutNativeCS );
Note that the PPRT_PRINTER_INFO has a tray member, but this does not get passed to the final PCF document.
Remember that the JDE “printer definition language” string tells you what DLL and what function is being used to massage your PDF stream into PS or PCL. I was able to tell the DLL and function name from there also.
Jdekrnl.dll and function _prtFilter_ConvertToPCL@20
PCL background
As stated before, there is a PCL string at the beginning of a print file that tells the printer what it should do with the stream that is coming at it. I was able to refer to the following excellent website to find the kind of PCL commands I’d be looking for. http://pcl.to/reference/
I’m expecting that there is a string in my file that specifies which tray the print job needs to go to (Ec&l#H), I want to modify this. I’m guessing that I will find a complete PCL string somewhere in the function space.
Note that escape is Hex 1B 26 6C (30 39) 48
This sequence could not be found, but I did find all of the other strings, see below:
From above you can see that it’s building the various codes in this block of executable. You cannot just add code here, you need to be careful what you change. There are all sort od checks and boundaries that need to be maintained.
The actual output
To see what JDE was doing with the output, I opened the .spl file. Windows printing (for a print server) writes all of the print files to %SystemRoot%\SYSTEM32\SPOOL\PRINTERS. So if you pause your printer, you can intercept the output files and see what the heck JDE is putting at the front if the PDF.
The actual PCL file looks like this: C:\winnt\system32\spooler\printer\*.SHD (printer info) and .SPL (file from JDE)
%-12345XE&l1X&u300D&l26A&l1O&l0E&l0L*p0x0Y*c8418x5952Y*c0T&k2G
*r3U
(s1p7.00v0s3b16602T*p2445.208x136.458Y(19U24/
So it is sending:
Reset
Copies
DPI
Paper Type
Orientation
Define Top Margin at # Lines
Define Left Margin at Column #
PCL absolute positioning
Unsure
PCL Line termnialtion
It is not sending TRAY information, so why isn’t the printer using the tray that we have defined?
So now what can we do, the tray info is not being sent!.
The solution:
So, I tried hacking the paper type, but had no real control on how to ensure that the correct tray was being passed into the command string. What I did determine what that the default # of copies was 1 – so this was not needed.
When I say hack the paper type, Change the A in &l26A to H and then try different paper types. This did not work for a number of reasons. Firstly the PDF’s were getting generated based upon the papersize and secondly you can’t print a letter based report to an A4 printer – JDE still embeds the printer paper type that the report was run against.
Therefore I hacked the jdekrnl.dll file (well a copy) to change the command for # of copies to tray selection. I changed the X in &l1X to a H. Therefore when you passed in a 1 for number of copies, this would use tray 1. Pass in a 2 for copies, this will use tray 2 but only print 1 copy.
So, when you choose my printer, which uses my custom “printer definition language” which uses the hacked jdekrnl2.dll file. This swaps copies for output tray.
I used a hex editor to change the PCL commands embedded into the PCL file that is send to the printer.
So the code now interprets the count of prints to fill out what goes into the tray selection value.
Note that this is the server version of jdekrnl.dll. I’ve called it jdekrnl2.dll and have located a master version of it in \\xxx\E811\DLL_HACK
So this is a safe mod, what are the net effects.
· Jdekrnl2.dll is ONLY used for printing with tray selection
· You cannot choose “number of copies” for the T2 printer, it must be 1 to choose the green paper. It seems that the RICOH tray selection codes, which are not the same as HP standard ones. 102 is second tray etc, a little weird.
Therefore any job that goes to \\xxx\PROPSRIC7001T2 from JDE will print on green paper if you choose 1 copy. Choosing 2 or 3 blocks the printer... I think that you need to choose 102 or 202 based upon the following table:
If there is a tools release, this file should stay (the way new tools releases currently work).
Hex view of the code in the DLL, this is where the printf are defined for the PCL codes. Note also that they bytes are little endian, so you need to be a little careful about which ones to change.
No comments:
Post a Comment