parent
a30600943d
commit
8072d0b194
@ -41,6 +41,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@odit/class-validator-jsonschema": "^2.1.1",
|
"@odit/class-validator-jsonschema": "^2.1.1",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
"bwip-js": "^2.0.12",
|
||||||
"cheerio": "^1.0.0-rc.5",
|
"cheerio": "^1.0.0-rc.5",
|
||||||
"class-transformer": "0.3.1",
|
"class-transformer": "0.3.1",
|
||||||
"class-validator": "^0.13.1",
|
"class-validator": "^0.13.1",
|
||||||
|
@ -179,6 +179,25 @@ export class PdfCreator {
|
|||||||
return <Buffer>(await mergedPdf.save());
|
return <Buffer>(await mergedPdf.save());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple barcode generation function using default params suitable for usage in pdfs.
|
||||||
|
* Generates the barcodes as base64-encoded png.
|
||||||
|
* @param type Barcode type according to this list: https://github.com/metafloor/bwip-js/wiki/BWIPP-Barcode-Types
|
||||||
|
* @param content Barcode content/text - please remember that some formats only support certain input types.
|
||||||
|
* @returns Barcode image as base64 encoded png string.
|
||||||
|
*/
|
||||||
|
public async generateBarcode(type: string, content: string): Promise<String> {
|
||||||
|
let barcode: Buffer = await bwipjs.toBuffer({
|
||||||
|
bcid: type,
|
||||||
|
text: content,
|
||||||
|
scale: 3,
|
||||||
|
height: 10,
|
||||||
|
includetext: true,
|
||||||
|
textxalign: 'center',
|
||||||
|
});
|
||||||
|
return `data:$image/png;base64,${barcode.toString('base64')}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new dummy runner with halfspaces for all strings.
|
* Generates a new dummy runner with halfspaces for all strings.
|
||||||
* Can be used to generate empty sponsoring contracts.
|
* Can be used to generate empty sponsoring contracts.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user