I've just written a library called jsPDF which generates PDFs using Javascript alone.(我刚刚编写了一个名为jsPDF的库, 它只使用Javascript生成PDF。)
It's still very young, and I'll be adding features and bug fixes soon.(它还很年轻,我很快就会添加功能和错误修复。) Also got a few ideas for workarounds in browsers that do not support Data URIs.(还有一些关于不支持数据URI的浏览器的变通方法的想法。) It's licensed under a liberal MIT license.(它是在自由MIT许可下获得许可的。)
I came across this question before I started writing it and thought I'd come back and let you know :)(在我开始编写它之前我遇到过这个问题并且认为我会回来让你知道:))
Generate PDFs in Javascript(在Javascript中生成PDF)
Example create a "Hello World" PDF file.(示例创建“Hello World”PDF文件。)
// Default export is a4 paper, portrait, using milimeters for units var doc = new jsPDF() doc.text('Hello world!', 10, 10) doc.save('a4.pdf')
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…