Print.js icon indicating copy to clipboard operation
Print.js copied to clipboard

IPAD print Issue in chrome

Open shaangidwani opened this issue 5 years ago • 14 comments

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.

shaangidwani avatar May 23 '19 07:05 shaangidwani

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.

crabbly avatar May 23 '19 17:05 crabbly

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.

songlim327 avatar May 24 '19 03:05 songlim327

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.

crabbly avatar May 24 '19 13:05 crabbly

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.

crabbly avatar May 24 '19 13:05 crabbly

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?

songlim327 avatar May 27 '19 01:05 songlim327

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?

songlim327 avatar May 27 '19 01:05 songlim327

Hey @songlim327, Yes, please do. That would be great. Any help is appreciated. Thank you!

crabbly avatar May 27 '19 03:05 crabbly

Hey @songlim327, Yes, please do. That would be great. Any help is appreciated. Thank you!

crabbly avatar May 27 '19 03:05 crabbly

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?

Chaitanya21 avatar Jul 01 '19 05:07 Chaitanya21

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?

Chaitanya21 avatar Jul 01 '19 05:07 Chaitanya21

anyone got anything please help.

shaangidwani avatar Jul 16 '19 13:07 shaangidwani

any solution?

RodrigoDLopez avatar Aug 08 '19 20:08 RodrigoDLopez

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.

Chaitanya21 avatar Aug 09 '19 04:08 Chaitanya21

I wonder if this is related: https://github.com/jasonday/printThis/issues/152#issuecomment-511628889

evanb2 avatar Dec 16 '19 22:12 evanb2

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?

timoostrich avatar Mar 17 '22 17:03 timoostrich

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.

image

uavn avatar Nov 21 '22 15:11 uavn

@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);
	}
}

timoostrich avatar Jan 31 '23 09:01 timoostrich