From 75d2ac3c5f80f8440b6d48c33b15ef17565559b3 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Mon, 8 Feb 2021 09:47:28 +0100 Subject: [PATCH] Added todo ref #13 --- src/PdfCreator.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PdfCreator.ts b/src/PdfCreator.ts index d1e17fd..2014fb7 100644 --- a/src/PdfCreator.ts +++ b/src/PdfCreator.ts @@ -2,15 +2,18 @@ import axios from 'axios'; import bwipjs from "bwip-js"; import cheerio from "cheerio"; import fs from "fs"; -import Handlebars from 'handlebars'; +import handlebars from 'handlebars'; import i18next from "i18next"; import Backend from 'i18next-fs-backend'; import mime from "mime-types"; import path from 'path'; import { PDFDocument } from 'pdf-lib'; +import promisedHandlebars from "promised-handlebars"; import puppeteer from "puppeteer"; import { Runner } from './models/Runner'; import { RunnerGroup } from './models/RunnerGroup'; + +const Handlebars = promisedHandlebars(handlebars); /** * This class is responsible for all things pdf creation. * This uses the html templates from src/templates. @@ -68,7 +71,6 @@ export class PdfCreator { '--use-gl=swiftshader', '--no-sandbox' ]; - await i18next .use(Backend) .init({ @@ -85,7 +87,8 @@ export class PdfCreator { ); await Handlebars.registerHelper('--bc', function (str) { - return "data:image"; + //TODO: Fix the async behaviour + return PdfCreator.generateBarcode("code39", str.toString()); } ); this.browser = await puppeteer.launch({ headless: true, args: minimal_args });