Printing and Downloading files
What is the best/recommended way, from a web app, of programatically:
[LIST=1][*]printing a file to a local printer?[*]downloading a file to a local drive?[/LIST]
Although I say "programatically", there will be user interaction; for printing I need to get up a printer selection dialog, while for downloading I need to get up a save/save as dialog.
I have found "kind of" solutions for these, but I am not really happy with them. :(
I know the users can, for instance, right-click on things in the browser to achieve this, but I'd like uniform mechanisms to do them in the code which work in all supported browsers.
Mike
Re: Printing and Downloading files
Hello, I think you can download files using [URL="https://docs.dataaccess.com/dataflexhelp/mergedProjects/VDFClassRef/cWebResourceManager-Function-DownloadURL.htm?rhhlterm=downloadurl&rhsyns=%20"]DownloadURL[/URL] or [URL="https://docs.dataaccess.com/dataflexhelp/mergedProjects/VDFClassRef/cWebResourceManager-Function-CustomDownloadURL.htm?rhhlterm=customdownloadurl&rhsyns=%20"]CustomDownload[/URL]. Remember to register the folder in which you have your files before using those functions with [URL="https://docs.dataaccess.com/dataflexhelp/mergedProjects/VDFClassRef/cWebResourceManager-Procedure-RegisterDownloadFolder.htm?rhhlterm=registerdownloadfolder&rhsyns=%20"]RegisterDownloadFolder[/URL] or you will get an error (Error HTTP 403.2 - Invalid download folder). However for the print question, I don't know if you can actually print a file directly from the browser, perhaps you need to download it before.
Re: Printing and Downloading files
Thanks Alberto, but I knew about those - and registering the folders.
I have a nasty bodge working for printing: I open a new window (JavaScript Window.open()) with the appropriate URL (from that DownloadURL method), then in its onload event do print(). That pops up the browser's printer dialog and I can send it to the appropriate printer. However it is:
[LIST=1][*]Ugly[*]Doesn't work in IE[/LIST]
So I was looking to see if anybody had better solutions. :(
Mike
Re: Printing and Downloading files
I found [URL="https://printjs.crabbly.com/"]this[/URL], maybe it would help. I don't know if it has any way to bypass the printer dialog of the browser if that is what you are after. And there are caveats.
Edit: Also found [URL="https://www.printnode.com/en"]this[/URL], which maybe sounds more like what you want, but sounds like it requires installing additional client software and has a subscription pricing model.
Re: Printing and Downloading files
If it is a file with a known extension (like PDF, doc, csv, rtf) just link it in a cWebiframe. That has worked so far for me. People can click on it and chose to print or save.
Re: Printing and Downloading files
Thanks Matt
I'm digging into their code now to see how they do it. :)
I'm not trying to bypass the printer dialog - I need that!
Mike
Re: Printing and Downloading files
Hi Mike,
I use DR for all this and the users love the default setup. It gives them the flexibility of printing to any printer on the network or downloading a PDF to be stored and/or emailed, although I am working on the best way to send reports via email with minimal user interaction. For this, I'll be using Chilkat for both Winapps and Webapps. This part, though, is still in the planning phase where I'll be writing a generic, but flexible, Windows and Web version.