From 6b059c401192060bf0429521228b2ad3f556421f Mon Sep 17 00:00:00 2001 From: raphael Date: Mon, 18 Mar 2019 10:30:41 +0100 Subject: [PATCH] also render text when whiteboard is exported as img --- public/js/whiteboard.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/public/js/whiteboard.js b/public/js/whiteboard.js index 7967a4e..018f6b6 100644 --- a/public/js/whiteboard.js +++ b/public/js/whiteboard.js @@ -747,6 +747,23 @@ var whiteboard = { copyCanvas.height = height; var ctx = copyCanvas.getContext("2d"); + $.each($(".textBox"), function() { + var textContainer = $(this) + var textEl = $(this).find(".textContent"); + var text = textEl.text(); + var fontSize = textEl.css('font-size'); + var fontColor = textEl.css('color'); + var p = textContainer.position(); + var left = Math.round(p.left * 100) / 100; + var top = Math.round(p.top * 100) / 100; + top+=25; //Fix top position + console.log(text, fontSize, fontColor, left, top) + ctx.font = fontSize+" monospace"; + ctx.fillStyle = fontColor; + ctx.fillText(text, left, top); + + }); + $.each(_this.imgContainer.find("img"), function () { var width = $(this).width(); var height = $(this).height();