4

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?

Fibericon
  • 5,684
  • 12
  • 37
  • 64

2 Answers2

6

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).

Ben
  • 5,117
  • 2
  • 27
  • 26
1

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

Danilo Valente
  • 11,270
  • 8
  • 53
  • 67
albert
  • 8,112
  • 3
  • 47
  • 63