简体   繁体   English

如何从动力学JS中获取画布对象?

[英]How to get canvas object from kineticjs?

I'm working on an existing project which uses Kinetic.js to generate base64 dataUrl from canvas. 我正在研究一个现有的项目,该项目使用Kinetic.js从画布生成base64 dataUrl。 (now I can export this dataUrl to png/jpg perfectly) (现在我可以将此dataUrl完美导出到png / jpg了)

I also need to export content on canvas to PDF file. 我还需要将画布上的内容导出到PDF文件。 I'm using jsPDF for this. 我为此使用jsPDF。

The problem is jsPDF doesn't work properly when the content of canvas is spread on multiple pages. 问题是当画布的内容分散在多个页面上时,jsPDF无法正常工作。

I found a solution for this here: https://github.com/MrRio/jsPDF/issues/434#issuecomment-249697715 我在这里找到了解决方案: 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 这就是为什么我需要从动力学dataURL获取画布以便检索canvas.width,canvas.height

Do you have any idea on this? 您对此有什么想法吗? Thank you very much. 非常感谢你。

var nativeCanvas = layer.getCanvas()._canvas;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM