开发者

Converting canvas to pdf

I've been looking into this for a while, but the closest thing I've come up with is .toDataUrl(), which seems to only be used for bitmap image formats. What I really need is to be able to save the canvas contents to a pdf, and be able to specify page breaks where appropriate. Is there a function in javascript to do so, 开发者_开发问答or will I have to do this with an apache command line tool?


It is possible to generate PDF documents using Javascript, but I'm yet to come across a framework that is mature enough to use.

What you could do is use some PHP PDF library, such as FPDF, and post your image data to a PHP script that generates the PDF document. Better yet you could use the AJAX method to generate the PDF without a page refresh.

When attaching images just specify the data URL as the image URL (although I haven't tested, it should work).


try pdf.js....idk if it'll work with canvas off the bat, but worth a looksie http://badassjs.com/post/708922912/pdf-js-create-pdfs-in-javascript

GitHub Link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜