crabbly / Print.js

A tiny javascript library to help printing from the web.
MIT License
4.29k stars 672 forks source link

iPhoneX Safari - pure html, does not find Print Dialog and therefore fails to print #342

Closed andyhill2 closed 3 years ago

andyhill2 commented 5 years ago

iPhoneX Safari - pure html, does not find Print Dialog and therefore fails to print.

Works fine on Desktop Chrome.

Please advise

andyhill2 commented 5 years ago

My framework is UniGUI and I resolved this problem by adding a timing delay.

andyhill2 commented 5 years ago

My solution worked for Safari and Chrome but NOT EDGE

andyhill2 commented 5 years ago

My solution worked for Safari and Chrome but NOT EDGE

Can anyone shed light on why ?

crabbly commented 5 years ago

Hi @andyhill2, I tested html print in Edge on Windows 10 and it worked. What is your OS and version?

andyhill2 commented 5 years ago

Firstly Windows 10 Pro (latest update) for the Desktop Edge and Chrome Testing.

I am using the UniGUI Framework (wrapper around Sencha) under Delphi (Object Pascal) for my WebApp.

For Desktop Chrome and Mobile Safari to work I have to add a delay as follows:-

htmFrame.JSInterface.JSCode('Ext.defer(function(){'#1'.iframe.contentWindow.print()}, 100);');

There was some chatter saying the Print function executes before the page is rendered, however no amount of delays allow Desktop Edge to print (button just blinks when pressed).

htmFrame.HTML.Add('&nbsp;<button type="button" onclick="printJS({printable: [''myTable''], type: ''html''})">Print via: Mobile Safari -or- Desktop Chrome</button>');

crabbly commented 3 years ago

Mobile browser support is still quite weak due to different behavior between mobile and desktop browsers Api. Unfortunately. Closing this is favor of #33. I hope we can eventually improve this.