2

Trying to load an external pdf url for print using PrintJS, getting SecurityError: Blocked a frame with origin "URL" from accessing a cross-origin frame. Same application is working fine in Chrome browser on windows.

Krishnakumar C
  • 179
  • 1
  • 9
  • The library fetches and cache the external pdf into a local blob before using the iframe to dispatch the job. This should fix the cross-origin issue. Please post an example, more details or you code here so we can help you further. – crabbly Sep 26 '20 at 18:00
  • @crabbly I am also facing the exact issue. in chrome mobile browser pdf is not shown. – kritikaTalwar Aug 30 '22 at 06:36

1 Answers1

0

Same issue from me, code is working fine on Safari (MacBook) but fails on Chrome (Android).

const handlePrintLabel = () => {
    setValue('isFull', true);

    trigger().then((result) => {
        if (result) {
            axiosInstance.current.post(`/api/.../request...`, {
                headers: {
                    'Content-Type': 'application/json',
                    'Accept': 'application/text'
                }
            }).then((response) => {
                printJS({printable: response.data, type: 'pdf', base64: true})
            }).catch((error) => {
                if (error instanceof AxiosError) {
                    throw Error(`Nieznany błąd: ${error.message}`)
                } else {
                    throw error
                }
            })
        }
    }).finally(() => setValue('isFull', false))
}

Error: init.js:26 Uncaught DOMException: Blocked a frame with origin "https://XXX.team" from accessing a cross-origin frame. at performPrint (https://XXX.unibe.team/static/js/18.chunk.js:1324:43) at iframeElement.onload (https://XXX.team/static/js/18.chunk.js:1278:19)