!Printers change selected printer without GUI
Ewen Pring (3163) 2 posts |
Could !Printers be modified to listen for and act on new WIMP User Messages to change and to query the currently selected printer? AFAIK the only way to change is by selecting a different printer with the mouse on the icon bar icons (or saving settings to file within !Printers which includes the selected printer). A command based method of doing this could be used e.g. by an app to temporarily select a printer called say “PDF”, print to it, then go back to the original. Changing the printer would just need to include the name of the desired printer, and then return a fail or success message accordingly. Querying the printer would just return a fail or the name of the selected printer. (You may see where I’m going with this- Ovation Pro has no built in export to PDF feature, this could provide an alternative, especially since !PrintPDF has recently gained an external API which allows WUMs to communicate desired PDF filenames). |
Dave Higton (1515) 3534 posts |
What you ask for looks entirely reasonable. But there’s trouble ahead… I’ve had cause to look at !Printers quite a lot over the last year or so, and it’s full of problems. It isn’t able to send to modern printers via IPP, as that requires bidirectional communication via HTTP. There isn’t a proper mechanism to make Printers aware of available feed trays or whether duplexing is available. There isn’t a proper method to send feed tray or duplexing selection to the rasterising module – this is important as it has to be put into the page headers of the data stream. And it’s easy give Printers a printer definition file that’s wrong in some way, save choices, and then Printers simply crashes and makes it impossible to repair the situation without restoring it and its choices from a backup, or re-installing it. It’s a big application, written in BASIC, and even the unsquashed version is a challenge for anyone to read and make sense of. It’s a bag of nails, and it wants a replacement writing from scratch. |
Rick Murray (539) 13850 posts |
This. When Printers is happy, all is good. But get it upset and it’ll die horribly and keep dying horribly 1. It’s like walking on eggshells. 1 I call it Kenny, ’nuff said. |
Clive Semmens (2335) 3276 posts |
I’ve not attempted to use a printer attached to RISCOS for years. I send files to the Apple and print from that. |
Rick Murray (539) 13850 posts |
I used to make PDFs to print from Android, or just use the Windows version of OvationPro… but that was mostly because RISC OS only managed to talk to my laser. Dave’s driver fixes that. Now I can shoot stuff from RISC OS just as easily as from my phone. Well, not quite but that’s because of how outdated Printers is, making multiple printer definitions fixes that. Amusingly, the IPP driver gives far better results than iOS7 with AirPrint…which could always be relied upon to screw it up. Want to print a thumbnail the size of an entire piece of paper? Done. Want to print a screenshot cleverly rotating it to fit the paper longest width (and this cutting off huge pieces of the top and bottom)? Done. Want to print everything at “best” with no option to select the resolution or output quality or even paper type? Done. Actually, that last one appears to be an actual limitation in AirPrint/IPP that you don’t get the same set of options as the printer can normally support 1, but since Apple invented AirPrint, it’s still their fault. ;) 1 Example – my printer claims various different resolutions, which are probably implemented using various print types (single pass (draft), interleaved pass (normal), interleaved and overlaid pass (fine/best)). However, the IPP driver only supports 300dpi as that’s the only thing the printer claims to understand. |
Dave Higton (1515) 3534 posts |
The version I’m working on should make it just as easy. Memorised printer definition(s) in the transport app; single step printing (no need to drag a Printout file to the transport app – it happens automatically). |
Ewen Pring (3163) 2 posts |
Understood about all the other problems with configuring and using !Printers. |
Dave Higton (1515) 3534 posts |
Correct. The work I’m doing is on new stuff that works with Printers. I looked at Printers to see if it might be possible to extend it to do more of the necessary things to support IPP, but gave it up as a nigh-impossible task. |
Matthew Phillips (473) 721 posts |
EasiWriter’s PDF export relies on a PostScript printer being active (which could include a “PDF printer” as provided by PrintPDF). I am not sure how it works behind the scenes, but if you try to export a PDF when a non-PostScript printer is selected, EasiWriter will put up an error and prompt you to select a different printer. Interestingly you can quit !Printers from the iconbar and EasiWriter will still happily export PDFs providing the last active printer was a PostScript one. When I implemented the mail-merge PDF attachments in ImpEmail for which the new PrintPDF API was initially developed, I took a similar approach of warning the user if things did not appear to be set up correctly. The application uses PDriver_Info, and checks the top 16 bits of the value returns in R0 to see if they are zero. If not, it will not be a PostScript driver. On top of this, the application also reads Choices:Printers.Settings, looks for the current printer name (also read using PDriver_Info), and inspects the “fl” setting which defines an output file. This is checked to make sure it is the value that would be expected for PrintPDF or PDFMaker. If any of these conditions are not satisfied the user is warned to set things up correctly. It must be possible to extend the RISC OS printing system with an API in the way you suggest, but I have not looked into this. Impact itself has an action script command which does select a specific printer by name. This is done by the dodgy method of counting the icons on the iconbar (window handle -2) and then working through them to identify which ones belong to the printer manager. You can do this by using Wimp_SendMessage with R0 set to 19, R2 set to -2 and R3 set to the icon number. The Wimp will then fill in R2 with the task handle that owns the icon, and you can look up its name with TaskManager_TaskNameFromHandle. If it is “Printer Manager” Impact then sends a mouse-click to the icon, and waits for the Message_SetPrinter to be generated by the printer manager. The name of the currently-selected printer is then inspected using PDriver_Info and if it’s not the one required, the loop continues to click on each Printer Manager icon in turn until we hit on the right one. I inherited this code from the original developer of Impact. It seems to work, but I hesitate to recommend this approach! |
Alan Adams (2486) 1149 posts |
Some random thoughts about this, some of which might be plain wrong. One thing I can’t find a way to do with RISC OS / PS3 / Duplex driver is to tell the printer that the paper type has changed to card. This is necessary with one of my lasers, otherwise the toner doesn’t fuse correctly. I have to use Windows to connect to the printer to change this, and change back afterwards. (The printer’s tiny screen and grey-on-darker-grey text is unusable.) |
Robert Hampton (1923) 57 posts |
Would there be any merit in a !Printers bounty? For a re-write in C and adding support for some of the features modern printers need? |
Steve Pampling (1551) 8172 posts |
The method of doing that varies, I have seen printers that require SNMP access to read and change the printer settings, or detect paper out etc. But yes, Printers does require a re-write. |
Chris Mahoney (1684) 2165 posts |
Quick story time: At work, the large-format printer suddenly spooled up, and proceeded to print a one-page A4 document in the upper-left corner of an A0 sheet. The “custodian” of the printer duly checked the logs, rolled up the print, put it in a tube, and sent it to the likely-perplexed responsible staff member (in another city) through the internal mail. |