Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
139 views
in Technique[技术] by (71.8m points)

javascript - 使用JavaScript生成PDF文件(Generating PDF files with JavaScript)

I'm trying to convert XML data into PDF files from a web page and I was hoping I could do this entirely within JavaScript.(我正在尝试将XML数据从网页转换为PDF文件,我希望我能在JavaScript中完全实现这一点。)

I need to be able to draw text, images and simple shapes.(我需要能够绘制文本,图像和简单的形状。) I would love to be able to do this entirely in the browser.(我希望能够在浏览器中完全做到这一点。)   ask by amoeba translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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> 


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...