简体   繁体   English

Html 窗口到 pdf 角度 8

[英]Html window to pdf angular 8

how can i save the html of my function as pdf in my file server?如何在文件服务器中将函数的 html 保存为 pdf?

this is my function with angular 8这是我的 angular 8 函数

 EnviarCorreo() { const report1 = document.getElementById('Reporte1').innerHTML; const mywindow = window.open('', 'Reporte Plan de Cumplimiento', 'height=,width=1200'); mywindow.document.write('<html><head><title>Reporte</title>'); mywindow.document.write('<link rel="icon" href="https://intranet.transaltisa.com.pe/transaltisa2/assets/img/favicon/favicon.ico" type="image/x-icon" />'); mywindow.document.write('</head><body >'); mywindow.document.write('<div style ="width:100%;font-size:30px;text-align:center;" >'); mywindow.document.write('Reporte Plan de Cumplimiento'); mywindow.document.write('</div>'); mywindow.document.write('<div style ="width:50%;float : left;" align="middle" >'); mywindow.document.write(report1); mywindow.document.write('</div>'); mywindow.document.close(); mywindow.focus(); mywindow.print();}

a couple of years ago I used directly headless chrome in my server to transfor a webpage (Html + css code) into a pdf and it worked really well.几年前,我在服务器中直接使用无头 chrome 将网页(Html + css 代码)转换为 pdf,效果非常好。 I prefered it to the pdf generator libraries that use canvas.与使用画布的 pdf 生成器库相比,我更喜欢它。 For your reference: https://github.com/puppeteer/puppeteer供您参考: https : //github.com/puppeteer/puppeteer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM