Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

388
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda