According to the source code the drivers for PCL 4, 5, and 5e (laserjet, lj4dith, lj4dithp, ljet2p, ljet3, ljet3d, ljet4, ljet4d, ljet4pjl, ljetplus) support tray selection (source file base/gdevdjet.c). In reality this does not work. If I supply the "-dMediaPosition=..." or "-d%MediaSource=..." options with small integer numbers (0, 1, 2, ...) on the command line, nothing changes in the output file. The attached patch fixes the problem. With the patch applied I can supply the "-dMediaPosition=..." with the integer numbers listed in the PCL documentation and appropriate trays get selected. Cited from PCL 5 documentation: ------------------------------------------------------------------------------ Designates one of four paper sources for paper feed. <ESC>&l#H #= 0 - Print current page (paper source remains unchanged) 1 - Feed paper from main paper source 2 - Feed paper from manual input 3 - Feed envelope from manual input 4 - Feed paper from alternate paper source 5 - Feed from optional large paper source 6 - Feed envelope from envelope feeder * 7 - Autoselect 8 - Feed paper from Tray 1 (right side tray) 20 - 39 - High Capacity Input (HCI) Trays 2-21 ------------------------------------------------------------------------------ The reason why I did not upload it directly is a possible interface change, but perhaps this is no problem as it did not work before, anyway. The changes now are that the paper tray selection is now directly taken from the setapgedevice dictionary variable /MediaPosition and not from /%MediaSource any more (like it was all the time done by the PCL-XL drivers pxlmono and pxlcolor, base/gdevpx.c). In addition, the old hpjet_make_init() function restricted the tray selection artificially to the main tray and the large capacity tray with the latter as default. On real printers there are many more tray options available. Interface change here is that the choices "0" and "1" for /MediaPosition have other meanings now (Default and Main instead of Large Capacity and Main), but this can be simply worked around by setting the large capacity tray as default in the printer's front panel menus. The big advantage of the change is that I can get rid of the ugly Perl workarounds in Foomatic. Now I can control trays by a decent "InputSlot" option which controls the Ghostscript command line option "-dMediaPosition=...".
Created attachment 4622 [details] pcl-input-slot-fix.patch Patch to allow paper tray selection via "-dMediaPosition=..." in PCL 4/5 drivers
I also did not find any documentation for these drivers, so there cannot be broken any documented behavior.
Patch committed to the Subversion Repository as revision 9241. Needs review whether it does not have any unwished side effects. Henrys recommended for getting this checked by Ray.
Thanks for the patch!
Quick suggestion - I found this bug here after finding it and fixing it in the code. (How sad I was that the order wasn't the other way around) - I believe we could make this a little better by requiring it to be a valid PCL5/6 tray option, and it's pretty straightforward. In hpjet_make_init we just set up an array full of the options, then loop through and only set it if our value passed in is a match, otherwise - don't put the parameter in the output file. I'll edit the patch, but I'm pasting this here as well first. ------ static void hpjet_make_init(gx_device_printer *pdev, char *buf, const char *str) { gx_device_hpjet *dev = (gx_device_hpjet *)pdev; int paper_source = -1; /* valid PCL5/6 Trays */ int paper_valid_trays[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }; if (dev->ManualFeed_set && dev->ManualFeed) paper_source = 2; else if (dev->MediaPosition_set && dev->MediaPosition >= 0 ){ int i; for (i = 0; i < countof(paper_valid_trays); i++){ if (dev->MediaPosition == paper_valid_trays[i]){ paper_source = dev->MediaPosition; break; } } } if (paper_source >= 0)....
shoot. I've not created a patch via SVN before - I'll try to get it in here soon.
Created attachment 4771 [details] pclMediaPosition.patch forcing valid tray selection...
Patch attached.
jason r. totten, thank you for your suggestion, but I would rather not force the tray values, as there can be non-HP printers which use PCL and they do not have necessarily the same scheme of tray numbers. Controlling the selection by only offering the correct ones for the printer currently in use, for example via a PPD file is the better alternative in my opinion.
Closing the bug again ...
(In reply to comment #1) > Created an attachment (id=4622) [details] > pcl-input-slot-fix.patch While working on bug 692914 (which does MediaSource/MediaType for the pxl driver, rather than pcl5), I looked at related code elsewhere and realize this patch introduced a bug - the ... param_write_int(plist, "MediaPosition", &dev->MediaPosition); ... chunk (copying media position from the driver back to the language core) should not be there, as it is clearly stated in the documentation that this information should only go one-way, from the language core to the driver; if that code is included, the code should be conditional on it being set previously, i.e. ... if (dev->MediaPosition_set) code = param_write_int(plist, "MediaPosition", &dev->MediaPosition); ... otherwise there is a danger of copying an unintialized value of bogus MediaPosition (=0, mostly) where none had ever been specified, into the language core and that bogus value gets copied back in the next invocation of param_read() .
Valgrind finds no uninitialized variables in valgrind ~/ghostpdl/debugbin/gs -sDEVICE=ljet4 -o /dev/null -c currentpagedevice setpagedevice What's wrong with 0 as an initial value for /MediaPosition ?
This has been idle for 9 years. If there is a genuine bug (comment #11) please open a new bug report for it.