Print.js
Print.js copied to clipboard
IPAD print Issue in chrome
while print in ipad chrome it will print all the html page with background instead of pdf or select particular form.
kindly help in this matter asap.
Hey @shaangidwani, looks like a browser compatibility issue, with Chrome in IOS. This has already been reported in #312.
I currently don't know on how we are going to fix this. Any ideas and feedback are welcomed. Thank you.
Hi @crabbly, just a suggestion from what I had did in my project. Instead of printing a file from an iframe, I had open it in a new tab with FileReader
. In there, users may proceed with the printing job just like Firefox in Windows.
I agree. We need to add this check for Chrome in IOS.
Until we improve support for this browsers, the target pdf should always open in a new tab to prevent errors.
The first thing we need to do is to create a method to our our brower.js
file that identifies Chrome in IOS.
I agree. We need to add this check for Chrome in IOS.
Until we improve support for this browsers, the target pdf should always open in a new tab to prevent errors.
The first thing we need to do is to create a method to our our brower.js
file that identifies Chrome in IOS.
I had forked a copy of Print.js and created a commit which add a method to identify Chrome in IOS. Should I submit a pull request?
I had forked a copy of Print.js and created a commit which add a method to identify Chrome in IOS. Should I submit a pull request?
Hey @songlim327, Yes, please do. That would be great. Any help is appreciated. Thank you!
Hey @songlim327, Yes, please do. That would be great. Any help is appreciated. Thank you!
Is there a fix for this yet? The goal of using PrintJS was to be able to open the print dialog box and immediately print without the need for a new tab. So this issue breaks that feature with iOS and Chrome. Anything that I might be able to do to help get it resolved?
Is there a fix for this yet? The goal of using PrintJS was to be able to open the print dialog box and immediately print without the need for a new tab. So this issue breaks that feature with iOS and Chrome. Anything that I might be able to do to help get it resolved?
anyone got anything please help.
any solution?
Nope. Never got a solution here. We even ended up getting a hold of Apple as older versions were working properly, but even so, never got a solution.
I wonder if this is related: https://github.com/jasonday/printThis/issues/152#issuecomment-511628889
Looks like this is still a problem on iOS/iPadOS Chrome and Firefox (Safari is fine). Any plans to fix it? Or are there other modern solutions?
Workaround, that I used:
function printJSFixed(options) {
if (-1 !== navigator.userAgent.toLowerCase().indexOf('crios') && 'pdf' === options.type && options.base64) {
var newWindow = window.open('', '_blank');
newWindow.document.write('<embed width="100%" height="100%" src="data:application/pdf;base64,' + options.printable + '" type="application/pdf"/>');
newWindow.print();
} else {
printJS(options);
}
}
and replace your call:
printJS({printable: pdf, type: 'pdf', base64: true});
to
printJSFixed({printable: pdf, type: 'pdf', base64: true});
for Chrome on iOS - it opens new tab, renders PDF in it, and calls print dialog, for the rest - print-js will be used like before.
@uavn Thanks for the fix using a popup. Seems to work, although popups / new windows may be blocked.
This is my version for printing an image (addressing ios/chrome and ios/firefox):
function printJSFixed(options) {
if (-1 !== navigator.userAgent.toLowerCase().indexOf('crios') || -1 !== navigator.userAgent.toLowerCase().indexOf('fxios')) {
const printWindow = window.open('', '_blank');
printWindow.document.write('<html><head><title>Print</title><style type="text/css">'+options.style+'</style></head><body>');
printWindow.document.write('<img style="height: 100%; width: auto;" src="'+options.printable+'"/>');
printWindow.document.write('</body></html>');
setTimeout(function() {
printWindow.print();
printWindow.close();
}, 100);
} else {
printJS(options);
}
}