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

get base64 string #41

Open
mdodge-ecgrow opened this issue Dec 11, 2019 · 2 comments
Open

get base64 string #41

mdodge-ecgrow opened this issue Dec 11, 2019 · 2 comments

Comments

@mdodge-ecgrow
Copy link

mdodge-ecgrow commented Dec 11, 2019

I'm trying to figure out how to just get the base64 string from my Barcode component. I can create the barcode on the page and if I copy the image location, I can see the actual base64 string that I want. https://codesandbox.io/s/determined-hawking-ow9mk
<Barcode value={'72527273070'} renderer={'img'} />
But how do I get that string in code? This is what I've tried:

const encodeSvg = reactElement => {
	return (
		'data:image/png;base64,' +
		escape(ReactDOMServer.renderToStaticMarkup(reactElement))
	);
};

const barcode = encodeSvg(
	<Barcode value={'72527273070'} renderer={'img'} />
);

console.log(barcode);
@NaroranDev
Copy link

Any updates?

@jhunexjun
Copy link

Check how did I fix it here: lindell/JsBarcode#337 (comment)

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

3 participants