Completed
Last Updated: 15 Nov 2019 08:34 by ADMIN
Luca Galbiati
Created on: 12 Sep 2019 10:51
Type: Bug Report
80
Print Dialog doesn't appear in Google Chrome 77.0.3865.75

The print functionality cannot be used in Google Chrome 77.0.3865.75 (lastest update).  The following error is displayed in the console of the browser: Resource interpreted as Document but transferred with MIME type application/pdf.

As an alternative, you can use other web browsers for printing. 

37 comments
ADMIN
Neli
Posted on: 15 Nov 2019 08:34

Hello Arunprasath,

You can test the solution or the given workarounds in Print dialog doesn't open in Google Chrome 77.0.3865.75 KB article. 

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Arunprasath
Posted on: 08 Nov 2019 10:21

I am also facing print issue in chrome 77 version. Using below code for print function 

pdfStamper.addJavaScript("this.print({bUI: true,bSilent:false,bShrinkToFit: true});");

 

Any body help to resolve the issue.

Naumand
Posted on: 01 Oct 2019 14:53

@XicoFininho your solution is okay as long as telerik implementation is done using the telerik reports WebApi inside MVC project (same domain).

Today with the 'Micro services' architectures most engineers choose to create another website only for the Telerik Reports WebApi.

This is how we have done it and your solutions does not work this way because of CORS issue with iframe printing something from a different domain.

And that's why the PrintJsis being used as a solution in the KB article.

Thanks

XicoFininho
Posted on: 30 Sep 2019 11:21

Hi, 

I don't think you specifically need to use PrintJS to print the report as that will just internally be calling window.print() anyway, all you need is to tell the iframe window to print. The issue in Chrome is that the iframe itself can't have JS to tell itself to print but the calling window opening the iframe still can still issue a print command. 

As per my last comment, when using the HTML5 report viewer you can either modify the JS source to add the 2 lines in (which was previously suggested by Nasko) or add the following JS in to modify the print function to call .print() on the opened iframe window which will work in any browser as long as it has a PDF plugin installed. Any browser without a PDF plugin will just ask to save the document first, there's no way around that of course. 

<script type="text/javascript">

$(function () {

var frame;
window.telerikReportViewer.printManager.print = function printPdf(src) {

if (!frame) {
frame = document.createElement("IFRAME");
frame.style.display = "none";
}

frame.src = src;
document.body.appendChild(frame);

// Bugfix for Chrome 77 requiring user input before printing
frame.contentWindow.focus();
frame.contentWindow.print();
};

});

</script>

 

The new KB article suggests modifying the JS source to add PrintJS but you can just add a couple lines to tell the iframe window to print. 

trv.printManager = function () { var iframe; function printDesktop(src) { if (!iframe) { iframe = document.createElement("IFRAME"); iframe.style = "position:absolute; left: -10000px; top: -10000px;"; } iframe.src = src; document.body.appendChild(iframe);

if (window.navigator.userAgent.toLowerCase().indexOf("chrome") > -1) {
    iframe.contentWindow.focus();
    iframe.contentWindow.print();
}

}

ADMIN
Neli
Posted on: 30 Sep 2019 10:44

Hi everyone,

You can find summarized information about the issue and the possible workarounds in Print dialog doesn't open in Google Chrome 77.0.3865.75 KB article. Note that if you are applying the Workaround for the HTML5-based Report Viewers, after each update of Telerik Reporting, the js files will be overwritten. This means that you need to implement the workaround again.

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
ASHISH
Posted on: 27 Sep 2019 10:25

You saved my time.

Many thanks to @XicoFininho.

 

Regards,

Ashish Gorana

 

Joao
Posted on: 25 Sep 2019 12:58

Thanks @XicoFininho that work like a charm.

(huuu huuuu :)

Joao Rios

 

XicoFininho
Posted on: 25 Sep 2019 12:00

If anyone else is using the HTML5Report Viewer and needs to fix their current version for Customers using Chrome 77 without upgrading, you can trigger the iframe window print using the code below. I wasn't able to modify the original JS script so I've done it slightly differently. 

Add this after the ReportViewer is loaded <telerik:ReportViewer ID="ReportViewer1" runat="server" />

 

<script type="text/javascript">

$(function () {

var frame;
window.telerikReportViewer.printManager.print = function printPdf(src) {

if (!frame) {
frame = document.createElement("IFRAME");
frame.style.display = "none";
}

frame.src = src;
document.body.appendChild(frame);

// Bugfix for Chrome 77 requiring user input before printing
frame.contentWindow.focus();
frame.contentWindow.print();
};

});

</script>

This simply just replaces the existing print function with this modifies version adding the .focus() and .print() calls to the iframe window. This seems to work around the issue where Chromium now requires user input before allowing printing. 

Simon
Posted on: 25 Sep 2019 03:51
Thanks @Thanh this was the ideal solution. As the current release of the reporting package simply had a work around.
Simon
Posted on: 25 Sep 2019 02:01
Any updates on this? We've also been getting more reports from our customers on this issue. Was this released in the 18 September release?
Thanh
Posted on: 24 Sep 2019 06:50

For those who uses HTML Telerik Report Viewer, using 3rd party library Print.js to print document. Replace code inside printDesktop function of telerikReportViewer-x.x.x.x.js:

<script src="/Scripts/Printjs/print.min.js"></script>

trv.printManager = function() {
        //var iframe;
        function printDesktop(src) {
            //if (!iframe) {
            //    iframe = document.createElement("IFRAME");
            //    iframe.style.display = "none";
            //}
            //iframe.src = src;
            //document.body.appendChild(iframe);
            printJS({ printable: src, type: 'pdf', showModal: true });        
        }

...

}();

This way has another benefit: This always display print dialog instead of downloading pdf file as in some web browsers.

Hope this helps!

dev
Posted on: 24 Sep 2019 05:19

The simplest of all workarounds is that Ctrl-P in the browser works instead of clicking the print button.

Still not a good solution for many users with this issue.

Also, none of the mentioned code changes work with v12.1.18.824.

ADMIN
Nasko
Posted on: 20 Sep 2019 05:55

Hi Michael,

Thank you very much for providing a solution for the legacy WebForms viewer. As a token of gratitude I've added Telerik points to your account.

Regards,
Nasko
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
bberdel
Posted on: 20 Sep 2019 00:06
Agreed, thx. Looks good.
YoonSoo
Posted on: 19 Sep 2019 22:48
Thanks Michael. Your code works well.
Michael
Posted on: 19 Sep 2019 20:42

To clarify:

 

<body>

<div>

<telerik:ReportViewer ID="ReportViewer" runat="server"></telerik:ReportViewer>

<script type="text/javascript">

ReportViewer.prototype.PrintReport = function () {

switch (this.defaultPrintFormat) {

case "Default":

this.DefaultPrint();

break;

case "PDF":

this.PrintAs("PDF");

previewFrame = document.getElementById(this.previewFrameID);

previewFrame.onload = function () { previewFrame.contentDocument.execCommand("print", true, null); }

break;

}

};

</script>

</div>

<body>

Michael
Posted on: 19 Sep 2019 20:39

Hello, to all wondering about a WebForms workaround, this is the solution we've come up with for our implementation. We override the ReportViewer.prototype.PrintReport (as described by Nasko) with the following:

 

ReportViewer.prototype.PrintReport = function () {

switch (this.defaultPrintFormat) {

case "Default":

this.DefaultPrint();

break;

case "PDF":

this.PrintAs("PDF");

previewFrame = document.getElementById(this.previewFrameID);

previewFrame.onload = function () { previewFrame.contentDocument.execCommand("print", true, null); }

break;

}

};

 

What this does is overrides it with a nearly identical version of the PrintReport function, with one major difference. If you look at the javascript that is being used by the ReportViewer object, you can see that we the ReportViewer is rendering the report to PDF in an iframe. By reading through some of Telerik's responses, it seems like this PDF is embedded with a command to cause the print, but that's the problem that Chrome has patched out.

What we're doing with this solution is waiting for the iframe to load, and then sending that inner document to print using a browser supported method: execCommand("print", true, null)

We decided to do this because we were also having a problems with the webform workaround adding and moving things in our report. All testing has indicated that this workaround behaves as expected. We just wanted to give this back to the community since, for many of us, the solution of "download the new version and migrate to HTML5 ReportViewer" is simply unacceptable.

n/a
Posted on: 19 Sep 2019 17:56
what would be the equivalent to "printMode: telerikReportViewer.PrintModes.FORCE_PDF_FILE" for the webforms report viewer? have the same problem.. tried the PrintAs script but it adds extra info to the print and only prints the current page
bberdel
Posted on: 19 Sep 2019 15:59
Also need a solution for webform reportviewer - it prints with PrintAs but it adds document information around the border...Date, url, filename, etc. 
YoonSoo
Posted on: 19 Sep 2019 13:37

The code of PrintAs("Default") prints only the page in the screen. I tried with PrintAs("PDF") but it doesn't work.

Any code to make it work properly for webform reportviewer?

ADMIN
Nasko
Posted on: 19 Sep 2019 07:31

Hello,

@Naumand, best case scenario would be to return to the previous behavior. However, the change made by Google to the Chrome PDF plug-in is intentional and intended to increase security and force the users to explicitly print the file via user interaction. The technical solution proposed in this request:

iframe.contentWindow.focus();
iframe.contentWindow.print();
does not work in other browsers and we cannot incorporate it at the moment. Thus, for the time being we decided that it is better to make the print button open the PDF with the auto-print script inside a new tab instead of loading it in a hidden iframe. We are still researching other approaches to handle this in a better and more user-friendly way.

 

 

@Dang Quang, The demo application is now fixed so you can give it a try. It will get updated with the latest reporting version in a timely manner so that the printing fix is available there as well. Thanks for reporting this one. We will further investigate what caused the report rendering unavailability in the first place.


@Licencias, there are a couple of ways to work around the issue:

  1. Set the viewer option printMode like this:
    printMode: telerikReportViewer.PrintModes.FORCE_PDF_FILE
    to fall back to PDF download with the PDF containing the auto-print script.
  2. Modify the report viewer JavaScript manually as suggested previously in this thread or open a support ticket and we will send the modified version to you.

 

Regards,
Nasko
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Dang Quang
Posted on: 19 Sep 2019 05:19

Trying to preview the fix on Demo page, but no report can be rendered on any browser. Please fix it asap.

https://demos.telerik.com/reporting/barcodes-report?&skinName=default

T
he error I've got from console logs is:

 

Refused to execute script from 'https://p.adsymptotic.com/d/px/?_pid=16218&_psign=0aa5badf92527f7732e22463d6fa4dbc&coopa=0&gdpr=0&gdpr_consent=&_puuid=b23cc6e3-b486-4f50-a157-c736e4c81836' because its MIME type ('image/gif') is not executable.

Naumand
Posted on: 18 Sep 2019 16:03

This one is not an accepted solution for thousand of end users and hundred of companies that are waiting for your release. Opening the report may be an accepted solution if you are in report viewer and click on print icon, but not when we  want to use direct print ( .PrintMode(PrintMode.ForcePDFPlugin)) for specific reports.

  1. The browser will first block this new window from opening automatically like the image below

 

   2. And  most important the user will have to still click CTRL + P  (after allowing the browser to open this kind of links)

 

Will this be you final resolution for this issue ? Opening the rendered PDF in a new tab ?


 

 

Licencias
Posted on: 18 Sep 2019 16:01
and those of us who have version 12.2.18.1129 and cannot update to the new version, how can we fix the problem?
ADMIN
Nasko
Posted on: 18 Sep 2019 15:42
Hi,

You can download the new R3 2019 release where the print button of the HTML5 Report Viewer now renders the report for print purposes and opens it in a new browser tab. The auto-print script is still embedded in the document, but Google Chrome will wait for user interaction in order to show its print dialog.

We are now testing more rigorously against the beta/canary build of Google Chrome so we are positive that such issues will be avoided in the future.


Dealing with this Google Chrome restriction in the obsolete ASP.NET WebForms report viewer would require to either upgrade to the HTML5 Report Viewer or to perform other actions on click of the print button by overriding the print function like so:
<script type="text/javascript">
    ReportViewer.prototype.PrintReport = function()
    {
      //do stuff
      this.PrintAs("Default");
    }
</script>


Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Lisa
Posted on: 18 Sep 2019 15:33
Was this fixed in today's release?
Jennifer
Posted on: 18 Sep 2019 14:57
Do you know when this will be fixed? 
Developer
Posted on: 18 Sep 2019 07:15

What is the equivalent workaround (by using printMode) for the old Telerik web form report viewer (Telerik.ReportViewer.WebForms.ReportViewer) ? We are using it and hundred of customers are struggling with the print issue. 

We need at least a workaround ASAP.

Pete
Posted on: 17 Sep 2019 18:43

This really worries me. I am losing confidence in the testing that is being done on these releases. We had to back out the last release because of an issue with defaulting data on grids. Now it appears they are not properly testing new versions of browsers. Like Concept said below, we also love the controls, but they cannot slip on quality. We have hundreds of users using the system, something like this is crippling to us. Telling them to use a different browser (away from their standard) is a low quality answer.

Mike
Posted on: 16 Sep 2019 15:50
Note line numbers and variable names may be different for you.  So just look for case sensitive "IFRAME".  The code will be soon after that.
Mike
Posted on: 16 Sep 2019 15:21

I would not recommend this moving forward but if you need a fix/workaround now. Here is what I did.  I deminified the file telerikReportViewer-##.#.#.###.min.js. Around line 580 you will see the code in the function called "e"

o.body.appendChild(t);

That is the code where the warning/error is thrown. Just after that line add the following code.  This will force the print.

t.contentWindow.focus();
t.contentWindow.print();
ADMIN
Neli
Posted on: 16 Sep 2019 14:39

Hello,

 

I would like to thank you for the kind words and the feedback which I forwarded. We have already taken action against such issues in the future. Hopefully, this problem will not be replicated anymore.

 

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Concept
Posted on: 13 Sep 2019 19:52

Thank you for working on it. We are eagerly waiting for the fix. Our customers are printing several reports each day and this problem really affects them.

I also have a feedback and I will appreciate if you can share it with your managers. Progress / Telerik is a big company and we expect you to test each version of Chrome vigorously when it is still in beta. Chrome 77 beta version was available almost a month ago, so if you had tested it when it was beta, the fix was going to be ready before the final release.

After every new release of Chrome, we feel very anxious that something in your controls will break with the new version. It happened a couple of times so far, and this really bothers us. I think it also hurts your credibility and our trust on you. You should invest more on testing each new browser version when they are still in beta. You should also test your new versions better. We also had problems with some bugs in your new versions. 

We love Telerik controls and we believe you can take care of this. 

ADMIN
Neli
Posted on: 13 Sep 2019 12:42

Hello,

We are sorry for the inconvenience this causes. We are doing our best to include the fix for the issue in our new release on Wednesday (18th of September). Once it works, we will post an update in the post and you will receive an email notification for that.

In general, the printing functionality is based on rendering the report in PDF format with special settings so when the PDF file opens in a browser, the PDF plug-in's Print dialog is directly invoked. By default, the viewer widget tries to use the PDF plug-in of the browser for printing. You can manually control the printing behavior through the printMode option when creating the report viewer widget.

This is the possible workaround at the moment.  By setting FORCE_PDF_FILE printMode option, the widget will always export the report document to a PDF file with the special print script. For more information, check Printing Reports article. For example in the HTML5 Report viewer, you need to add the following line in the initialization of the viewer:

printMode: telerikReportViewer.PrintModes.FORCE_PDF_FILE

 

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Đình
Posted on: 13 Sep 2019 08:18
Give me the solution to fix it as quickly as possible, thousands of customers are waiting.
Adam
Posted on: 12 Sep 2019 22:27

I have been seeing this exact situation with our reports; it appears that it was an intentional functionality change from Google:
https://pdfium.googlesource.com/pdfium.git/+/2021804f1b414c97667c03d7ab19daf66f6a19ef


It indicates that a mouse gesture/event may be required in order to allow the print.  Going to experiment, but that may be of use to some.

ADMIN
Neli
Posted on: 12 Sep 2019 11:13
Hi,

We will let you know in this post if there is a workaround which will allow the usage of the print functionality in the lasted version of Google Chrome (77.0.3865.75).

Regards,
Neli
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items