Printing Documents from a Web Page Using WebDAV Ajax Library

IT Hit WebDAV Ajax Library can print documents from a web page using a default printer.

Note: Printing functionality is available in WebDAV Ajax Library v5.11 and later versions.

Note: Printing functionality is available on Windows OS only. 

To print documents from a web page you can use DavProtocolEditDocument() JavaScript function with "Print" parameter:

ITHit.WebDAV.Client.DocManager.DavProtocolEditDocument(
        ['http://localhost:87654/folder/file.ext'], // Array of document URL(s)
        'http://localhost:87654/',                // Mount URL
        errorCallback,                            // Function to call if protocol app is not installed
        null,                                     // Reserved
        null,                                     // Which browser to copy cookies from: 'Current', 'None'
        null,                                     // Cookie(s) to copy.
        null,                                     // URL to navigate to if any cookie from the list is not found.
        'Print'                                   // Command to execute: 'Edit', 'OpenWith', 'Print'
);

To print multiple documents pass an array of documents as a fist parameter:

ITHit.WebDAV.Client.DocManager.DavProtocolEditDocument(
        ['http://localhost:87654/file1.ext','http://localhost:87654/file2.ext'] // Array of document URL(s)
        'http://localhost:87654/',                // Mount URL
        errorCallback,                            // Function to call if protocol app is not installed
        null,                                     // Reserved
        null,                                     // Which browser to copy cookies from: 'Current', 'None'
        null,                                     // Cookie(s) to copy.
        null,                                     // URL to navigate to if any cookie from the list is not found.
        'Print'                                   // Command to execute: 'Edit', 'OpenWith', 'Print'
);

Important! Do NOT call this function multiple times to print more than one document. This may not work in all web browsers due to web browser protocol limitations. Instead, pass ALL documents as a first parameter.

When printing a document, the application associated with a document (MS Word, Notepad, etc) will be visible in the taskbar in the minimized mode.

Configuring Default Printer

To print documents you must have a default printer configured. If the default printer is not configured the printer configuration window will be displayed.

You can find details about printer configuration on Windows here: https://support.microsoft.com/en-us/help/4028622/windows-10-how-to-set-a-default-printer

Next Article:

Do I Need to Install davX: Protocol on a Client Machine to Open Documents from a Web Page?