Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
662 B
1
Indexable
Never
const canvas = document.createElement('canvas');
canvas.width = 400;
canvas.height = 200;

const ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);

ctx.font = '30px Arial';
ctx.fillStyle = 'black';

const banglaText = 'বাংলায় চু;

const textWidth = ctx.measureText(banglaText).width;
const x = (canvas.width - textWidth) / 2;
const y = canvas.height / 2;

ctx.fillText(banglaText, x, y);

const dataURL = canvas.toDataURL();
const a = document.createElement('a');
a.href = dataURL;
a.download = 'bangla_text_image.png';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Leave a Comment