crabbly / Print.js

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

Cannot print on Android phone or Chrome with device toolbar #593

Open meier-andersen opened 3 years ago

meier-andersen commented 3 years ago

If I access https://printjs.crabbly.com/ from my Android Phone (Chrome) and try the first "Print PDF" example, nothing happens. I only seem to encounter this problem with PDF files. I am able to print other types such as HTML or JPG.

It is possible to replicate the same bug if you enter the webpage in Chrome and toggle on the device toolbar.

I have tried to implement print-js (1.5.0) in a vue application and here I experience the same problems. Works fine on normal size chrome. All Firefox sizes and all Safari sizes.

Phone: Samsung Galaxy S20 Android 11

If i look in the network tab I can see the following call: Request URL: blob:https://printjs.crabbly.com/df1f7828-96f6-4b44-8521-151111c9e13a Request Method: GET Status Code: 200 OK Referrer Policy: strict-origin-when-cross-origin

Response:

charleskoehl commented 2 years ago

We encountered this (or similar) error and our app recorded it in sentry.io. Here's some of the info it captured:

SecurityError: Blocked a frame with origin "https://pmg.app.perseus.id" from accessing a cross-origin frame.

../printJS/src/js/init.js
at line 26:29
      maxWidth: 800,
      properties: null,
      gridHeaderStyle: 'font-weight: bold; padding: 5px; border: 1px solid #dddddd;',
      gridStyle: 'border: 1px solid lightgray; margin-bottom: -1px;',
      showModal: false,
      onError: (error) => { throw error },
Source file not found.Configure Stack Trace Linking to fix this problem.
      onLoadingStart: null,
      onLoadingEnd: null,
      onPrintDialogClose: () => {},
      onIncompatibleBrowser: () => {},
      modalMessage: 'Retrieving Document...',