@@ -40,22 +40,23 @@ document.getElementById('generate-btn').addEventListener('click', () => {
4040} ) ;
4141
4242document . getElementById ( 'download-btn' ) . addEventListener ( 'click' , ( ) => {
43- const cert = document . getElementById ( 'certificate' ) ;
44-
45- // Ensure certificate is visible
46- cert . style . display = 'block' ;
47-
48- // Small delay to allow DOM to paint before capturing
49- setTimeout ( ( ) => {
50- const opt = {
51- margin : 0.5 ,
52- filename : 'bonafide_certificate.pdf' ,
53- image : { type : 'jpeg' , quality : 0.98 } ,
54- html2canvas : { scale : 2 } ,
55- jsPDF : { unit : 'in' , format : 'a4' , orientation : 'portrait' }
56- } ;
57-
58- html2pdf ( ) . set ( opt ) . from ( cert ) . save ( ) ;
59- console . error ( "errpr" , err ) ;
60- } , 500 ) ;
43+ const printCertificate = document . getElementById ( 'certificate' ) ;
44+
45+ // Ensure certificate is visible
46+ printCertificate . style . display = 'block' ;
47+ console . log ( "printCertificate" , printCertificate ) ;
48+
49+ // Small delay to allow DOM to paint before capturing
50+ setTimeout ( ( ) => {
51+ const opt = {
52+ margin : 0.5 ,
53+ filename : 'bonafide_certificate.pdf' ,
54+ image : { type : 'jpeg' , quality : 0.98 } ,
55+ html2canvas : { scale : 2 } ,
56+ jsPDF : { unit : 'in' , format : 'a4' , orientation : 'portrait' }
57+ } ;
58+
59+ html2pdf ( ) . set ( opt ) . from ( printCertificate ) . save ( ) ;
60+ } , 500 ) ;
61+ console . log ( "printCertificate" , printCertificate ) ;
6162} ) ;
0 commit comments