Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
innerHTML to PDF with jsPDF

Hello I'm trying to take innerHTML of the elements and put them into PDF. After generate PDF, the PDF file is blank.

What am I doing wrong?

add_action( 'template_redirect', 'pdf_to' );
function pdf_to(){
?> 
<script 
src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" 
integrity="sha512- 
GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
function to_pdf(){
    console.log("tutaj1");
    
    const btn = document.getElementById("pdf");

    btn.addEventListener("click", function(){
    var element = document.getElementById("test");
    console.log(element);
    html2pdf().from(element).save('filename.pdf');
    console.log("tutaj2");
    });
}
if (window.addEventListener) {
    window.addEventListener("load", to_pdf, false);
}
else if (window.attachEvent) {
    window.attachEvent("onload", to_pdf);
}
else {
    window.onload = to_pdf; 
}

</script>
<?php
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Okey, I discovered problem. I changed the jsPDF version to 9.0 Now it's works like should.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!