react-barcode icon indicating copy to clipboard operation
react-barcode copied to clipboard

get base64 string

Open mdodge-ecgrow opened this issue 6 years ago • 2 comments

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);

mdodge-ecgrow avatar Dec 11 '19 15:12 mdodge-ecgrow

Any updates?

NaroranDev avatar Dec 04 '20 08:12 NaroranDev

Check how did I fix it here: https://github.com/lindell/JsBarcode/issues/337#issuecomment-1482755112

jhunexjun avatar Mar 24 '23 12:03 jhunexjun