[英]How to add a javascript button to PDF that saves data to a (png) file?
[英]How to add Text IN a picture file (png) with javaScript?
我發現我不能用HTML做到這一點(在圖片中添加文字),我找到了一種使用JAVA的方法,但我很有興趣通過使用Javascript找到一種方法。
你可以用帆布做,
<canvas id="canvas" width="340" height="340"></canvas>
腳本,
function addTextToImage(imagePath, text) {
var circle_canvas = document.getElementById("canvas");
var context = circle_canvas.getContext("2d");
// Draw Image function
var img = new Image();
img.src = imagePath;
img.onload = function () {
context.drawImage(img, 0, 0);
context.lineWidth = 1;
context.fillStyle = "#CC00FF";
context.lineStyle = "#ffff00";
context.font = "18px sans-serif";
context.fillText(text, 50, 50);
};
}
addTextToImage("http://www.gravatar.com/avatar/0c7c99dec43bb0062494520e57f0b9ae?s=256&d=identicon&r=PG", "Your text");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.