Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example files need jspdf.debug.js that doesn't exist, causing ReferenceError: jsPDF is not defined #3706

Open
Aprillion opened this issue Feb 13, 2024 · 0 comments

Comments

@Aprillion
Copy link

HTML files in the examples folder, e.g. html2pdf/auto_break.html, point to a file that no longer exists:
<script src="../../dist/jspdf.debug.js"></script>

This is showing up as ReferenceError: jsPDF is not defined in browser console instead of rendering the iframe with PDF.

Workaround

  • clone repo
  • copy file dist/jspdf.umd.js to dist/jspdf.debug.js
  • add a line near the end of the file (e.g. right after line exports.jsPDF = jsPDF;) with code:
    window.jsPDF = jsPDF;
  • navigate to the local example file, e.g. http://127.0.0.1:8000/examples/html2pdf/auto_break.html
    (after starting the server with npm start)
  • the generated PDF is not perfect, especially in Firefox on Mac, but that's probably a known limitation when using html2canvas
    (please let me know if this only happens due to my workaround method and it would look better when using the library in a proper way):
    jsPDF html2pdf auto_break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant