Skip to content

How to clear the generated barcode in canvas? #50

@SyedSaifAli

Description

@SyedSaifAli

Hi,
I have successfully created the canvas.
Now, I want to clear this canvas with the click of a button.

<div id="bar_code">
  <Barcode renderer="canvas" value={"test"} font="trebuchet ms" height={50} /><br/>
</div>

on click of button, I am trying the code below,

var bar_cnv = document.getElementById('bar_code').firstChild;
var ctx2 = bar_cnv.getContext('2d');
ctx2.clearRect(0, 0, bar_cnv.width, bar_cnv.height);

But the canvas is not getting cleared.
Any help will be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions