Added barcode generatin

ref #19
This commit is contained in:
2021-02-09 19:15:08 +01:00
parent b77945a9e4
commit 5c075bce8b
3 changed files with 14 additions and 7 deletions

View File

@@ -123,7 +123,7 @@ export class PdfCreator {
* @param cards The runner cars you want to generate the cards for.
* @param locale The locale used for the cards (default:en)
*/
public async generateRunnerCards(cards: RunnerCard[], locale: string = "en"): Promise<Buffer> {
public async generateRunnerCards(cards: RunnerCard[], locale: string = "en", codeformat: string = config.codeformat): Promise<Buffer> {
if (cards.length > 10) {
let pdf_promises = new Array<Promise<Buffer>>();
let i, j;
@@ -138,7 +138,8 @@ export class PdfCreator {
await i18next.changeLanguage(locale);
const template_source = fs.readFileSync(`${this.templateDir}/runner_card.html`, 'utf8');
const template = Handlebars.compile(template_source);
const result = template({ cards, cards_swapped, eventname: "LfK! 2069" })
let result = template({ cards, cards_swapped, eventname: "LfK! 2069", codeformat: "qrcode" })
result = await awaitAsyncHandlebarHelpers(result);
const pdf = await this.renderPdf(result, { format: "A4", landscape: false });
return pdf
}