Search code examples
javascriptcanvashtml5-canvaskineticjsjspdf

How to get canvas object from kineticjs?


I'm working on an existing project which uses Kinetic.js to generate base64 dataUrl from canvas. (now I can export this dataUrl to png/jpg perfectly)

I also need to export content on canvas to PDF file. I'm using jsPDF for this.

The problem is jsPDF doesn't work properly when the content of canvas is spread on multiple pages.

I found a solution for this here: https://github.com/MrRio/jsPDF/issues/434#issuecomment-249697715

That's why I need to get canvas from kinetic dataURL in order to retrieve canvas.width, canvas.height

Do you have any idea on this? Thank you very much.


Solution

  • var nativeCanvas = layer.getCanvas()._canvas;