0

I need help for converting one text to image. Is there any way to do this by js or jquery.. ?

any help would be appreciated.

1
  • What have you looked into? What do you know about JS? We need a baseline to be able to help. Commented May 4, 2012 at 14:38

4 Answers 4

8

Use canvas and print the text on the canvas. After that canvas can be exported to an image.

<canvas id="e" width="200" height="200"></canvas>
<script>
  var canvas = document.getElementById("e");
  var context = canvas.getContext("2d");
  context.fillStyle = "blue";
  context.font = "bold 16px Arial";
  context.fillText("Your text", 100, 100);
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

Draw your text into a canvas tag.

var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');

ctx.fillText(myText, x, y);

Comments

0

There is a library that attempts to do this.

http://hertzen.com/experiments/jsfeedback/

Reads the DOM, from the html and render it to a canvas, fail on some, but in general works.

Comments

0

I suggest you use puppeteer with ejs for better speed. I used it and got like 80 MS speed (average), which is way faster than canvas or any other lib! If you want to use it, feel free to let me know.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.