html2canvas + jspdf 前端如何准确导出 pdf 文件?

网页中,html2canvas + jspdf 前端如何准确把指定 Dom 区域为 pdf 文件导出呢?

使用 html2canvas + jspdf 组合就可以了。
低层原理盲猜【有空也不会去看源码哈】,把 Dom 转 Image 再构建 pdf。Dom 转 Image 如何转?svg 的 forignObject 支持把 Dom 内嵌到 svg 里,然后可以通过给图片对象写入 base64 编码的 svg 流来实现。即: 继续阅读