I share barcode generation


#1

in an non visual plugin

this.getReactWebPackages = function() {
// Return dependencies that need to be included in the exported project’s package.json file.
// Each key is an npm package name that must be imported, and the value is the package version.
//
// Example:
// return { “somepackage”: “^1.2.3” }

return {“jsbarcode”:"^3.11.0",“canvas”:"^2.6.0"}
}

this.writesCustomReactWebComponent = false;

this.getReactWebComponentName = function() {
// Preferred class name for this component.
// The exporter may still need to modify this (e.g. if there already is a component by this name),
// so in the actual export method below, we must use the className value provided as a parameter.
return “testnonvisual”;
}

this.getReactWebImports = function(exporter) {
var arr = [ {varName: “JsBarcode”, path : “jsbarcode”}, {varName: “Canvas”, path : “canvas”}
];
return arr;
}

in a image transformer function

const JsBarcode = require(‘jsbarcode’);
const Canvas = require(“canvas”);

const canvas = Canvas.createCanvas();
JsBarcode(canvas, this.props.appActions.dataSlots[‘ds_xxx’]);
return canvas.toDataURL(“image/png”);