I'm using Paged.js to format and print an HTML-based document as a PDF. It was working fine until today, but now I'm getting the following errors in the browser console:
javascript
Uncaught SyntaxError: Cannot use import statement outside a module (at paged.js:1:1) Uncaught ReferenceError: PagedPolyfill is not defined Here’s how I was loading the library:
html
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
if (typeof Paged !== "undefined") {
Paged.polyfill();
} else {
console.error("Paged.js did not load correctly.");
}
});
</script>
My HTML file is opened directly from the desktop (without a local server), so I need a solution that works in this context.
What I've tried:
Has anyone else encountered this issue recently? Is there a workaround or an alternative way to integrate Paged.js in a standalone HTML file?
Thanks in advance!
I was also facing the same issue it was working earlier today. I've found another CDN which seems to be working.
<script src="https://cdn.jsdelivr.net/npm/pagedjs/dist/paged.polyfill.min.js"></script>