Search

Atalasoft Knowledge Base

INFO: Self Printing PDF No Longer Auto Prints in Chrome and IE Edge

Tananda
DotImage

DotImage web components do not have built in printing. For many years, we've used a bit of a workaround where we have you deliver a self-printing PDF to the browser.

Our PdfEncoder and PdfDocument classes both have a means to set that you want the PDF to be self printing. What we actually do to implement this is add a small JavaScript "on open" event that tells the reader to pop the print dialog

This works fine in Adobe Reader and in IE 11, but IE Edge and Google Chrome (they share the same underlying rendering engine) now disallow this js action

Workaround

Self printing PDFs will no longer self-print in IE Edge or Google Chrome as they previously did. but we may have a workaround...

Users can select the print option themselves or if they are using Acrobat Reader as their default PDF reader it should still auto start self printing PDFs

Early testing indicates that if you have a PDF loaded in Google Chrome's built in web browser the self printing part of the PDF does not seem to want to print, however, you can make a js call to windowObject.print();   so if you have existing code that follows some of our previous examples such as

unction onDocumentSaved(e) {
    if (e.success) {
        var request = $.ajax({
            url: 'WebViewingDemoResources/ProcessingHandler.ashx',
            data: {
                request: "PrintDocument",
                document: e.fileName,
            },
            dataType: 'json',
            success: function (data, status) {
                if (data.success != 'true') {
                    alert(data.error);
                }
                else {
                    var str = data.file;
                    var n = str.replace("~", "");
                    window.open(n, 'Download');      
                }
            }
        });
    }
}

Our testing shows that this seems to work:

function onDocumentSaved(e) {
    if (e.success) {
        var request = $.ajax({
            url: 'WebViewingDemoResources/ProcessingHandler.ashx',
            data: {
                request: "PrintDocument",
                document: e.fileName,
            },
            dataType: 'json',
            success: function (data, status) {
                if (data.success != 'true') {
                    alert(data.error);
                }
                else {
                    var str = data.file;
                    var n = str.replace("~", "");
                    var win = window.open(n, 'Download');
                    win.focus();
                    win.print();
                }
            }
        });
    }
}

The WebViewing Demo code will be updated with this shortly
Details
Last Modified: 2 Weeks Ago
Last Modified By: Tananda
Type: INFO
Rated 5 stars based on 1 vote
Article has been viewed 82 times.
Options
Also In This Category