美文网首页
前端html转pdf

前端html转pdf

作者: xiaoyao911209 | 来源:发表于2019-04-04 10:27 被阅读0次

    注:1、目前前端大段html转pdf的方法大多数都会使用canvas 截图的方法,所以生成的pdf打印出来都会稍微有颗粒感,如果对清晰度有严格的要求,可能需要另觅它法。

    2、大段文本转pdf也有不使用canvas截图的方法,就是用jspdf一句一句的拼成pdf,缺点:1)jspdf不支持中文,需要字体转码后引入,2)耗时。

    一:使用html2canvasjsPDF

    https://github.com/niklasvh/html2canvas

    https://github.com/MrRio/jsPDF

    <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js"></script>

    代码:

    css html script

    二:jspdf拼成pdf

    请参考

    http://www.hangge.com/blog/cache/detail_2207.html

    https://blog.csdn.net/kunga0814/article/details/81869183

    相关文章

      网友评论

          本文标题:前端html转pdf

          本文链接:https://www.haomeiwen.com/subject/ayyauqtx.html