Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to clear the generated barcode in canvas? #50

Open
SyedSaifAli opened this issue Mar 10, 2021 · 0 comments
Open

How to clear the generated barcode in canvas? #50

SyedSaifAli opened this issue Mar 10, 2021 · 0 comments

Comments

@SyedSaifAli
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant