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

381
Views
How to show print preview in electron?

I am using Cordova-electron with ReactJS to build a desktop application. we need to implement print-preview in our application instead of showing the default system dialog for printing. The community says there is no default way to achieve this in electron, we need to do it manually. I used html2pdf.js,jsPDF to generate PDF from the client-side but none of these are giving the exact PDF we need, all have some alignment issues, font issues, and page-break issues, etc. please suggest me a proper solution for this issue.

I am attaching code to generate PDF by using html2pdf.js which I have used

var opt = {
  margin: 1,
  filename: 'myfile.pdf',
  image: { type: 'jpeg', quality: 0.98 },
  html2canvas: { scale: 1, logging: true, width: '1024', dpi: 100, letterRendering: true },
  jsPDF: { unit: 'mm', orientation: 'portrait', format: 'a4' },
  pagebreak: { after: '.page-break' }
}
 var worker = html2pdf().set(opt).from(componentRef.current).to('pdf').output('blob').then(d => {
    console.log('pdf-file', d);
    var blob = new Blob([d], { type: "application/pdf" });
    console.log('Blob-pdf', blob);


    var url = URL.createObjectURL(blob);

    var printWindow = window.open(url, '', 'width=800,height=500');

  }).catch(d => {
    console.error('error in PDF generation', d);
  })


  
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Unfortunately, the electron does not have a print preview, you can use nw.js instead of the electron if you want a print preview

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!