From Canvas to PDF via AJAX

If you are ever in the peculiar position of having to convert a canvas tag into an image, post it via AJAX to a CFC and then generate a PDF then I have your solution.

The first file below is the HTML and JavaScript needed to generate a canvas image, convert it to a JavaScript image and ship it to CFC Land via AJAX. The second file is the first (non-functional) version of the CFC. The third file is the working version of the CFC. Hit me with a comment if you have any questions or have a more concise (or different) way of solving this problem. I also shared this problem…and the answer over at Stack Exchange.

UPDATE: Scroll down to the bottom of the code for a bonus SVG-to-Canvas-to-PNG conversion.

Bonus Code: SVG-to-Canvas-to-PNG!