[英]How to to make the canvas scrollable to contain multiple pages scanned pdf?
I'm beginner to HTML5. 我是HTML5的新手。
I use the Canvas to draw on it and i want to get the following abilities : 我使用画布在上面绘图,我想获得以下功能:
Allowing the canvas to be Expandable so if the image was set of scanned pdfs
, i can show all the images (pdf pages). 允许画布可扩展,因此,如果图像是scanned pdfs
集合,则我可以显示所有图像(pdf页面)。
I want the (Undo & Redo ) Functionality through the canvas . 我希望通过画布具有(撤消和重做)功能。
I've done this before by storing the canvas state using the toDataUrl method to an undo_array : 我之前通过使用toDataUrl方法将画布状态存储到undo_array来完成此操作:
var undo_array = [];
so before any change you do : 因此,在进行任何更改之前,您需要:
undo_array.push(myCanvas.toDataURL("image/png"));
now, when the undo button is pressed, just restore the previous picture : 现在,当按下撤消按钮时,只需恢复上一张图片:
var myImg = new Image();
oImg.onload = function() {
var ctx = document.getElementById("canvasID").getContext("2d");
ctx.drawImage(myImg, 0, 0);
}
myImg.src = undo_array.pop();
but if you also change the canvas's seize, i guess you can use another array to store/restore seize changes. 但是,如果您还更改了画布的抓取,我想您可以使用另一个数组来存储/恢复抓取更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.