parent
b77945a9e4
commit
5c075bce8b
@ -123,7 +123,7 @@ export class PdfCreator {
|
|||||||
* @param cards The runner cars you want to generate the cards for.
|
* @param cards The runner cars you want to generate the cards for.
|
||||||
* @param locale The locale used for the cards (default:en)
|
* @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) {
|
if (cards.length > 10) {
|
||||||
let pdf_promises = new Array<Promise<Buffer>>();
|
let pdf_promises = new Array<Promise<Buffer>>();
|
||||||
let i, j;
|
let i, j;
|
||||||
@ -138,7 +138,8 @@ export class PdfCreator {
|
|||||||
await i18next.changeLanguage(locale);
|
await i18next.changeLanguage(locale);
|
||||||
const template_source = fs.readFileSync(`${this.templateDir}/runner_card.html`, 'utf8');
|
const template_source = fs.readFileSync(`${this.templateDir}/runner_card.html`, 'utf8');
|
||||||
const template = Handlebars.compile(template_source);
|
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 });
|
const pdf = await this.renderPdf(result, { format: "A4", landscape: false });
|
||||||
return pdf
|
return pdf
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import bwipjs from "bwip-js";
|
|||||||
|
|
||||||
export const asyncHelpers = new AsyncHelpers();
|
export const asyncHelpers = new AsyncHelpers();
|
||||||
async function generateBarcode(str, options, emtpy, cb) {
|
async function generateBarcode(str, options, emtpy, cb) {
|
||||||
|
if (str == null) { cb(null, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg=="); return; }
|
||||||
let res = await generateBase64Barcode(options.toString(), str.toString());
|
let res = await generateBase64Barcode(options.toString(), str.toString());
|
||||||
cb(null, res);
|
cb(null, res);
|
||||||
}
|
}
|
||||||
@ -18,7 +19,7 @@ export async function generateBase64Barcode(type: string, content: string): Prom
|
|||||||
height: 10,
|
height: 10,
|
||||||
width: 10,
|
width: 10,
|
||||||
includetext: true,
|
includetext: true,
|
||||||
textxalign: 'center',
|
textxalign: 'center'
|
||||||
}
|
}
|
||||||
if (type != "qrcode") {
|
if (type != "qrcode") {
|
||||||
delete options.width;
|
delete options.width;
|
||||||
|
@ -38,15 +38,17 @@
|
|||||||
<div class="columns" style="height: 6rem; overflow: hidden;">
|
<div class="columns" style="height: 6rem; overflow: hidden;">
|
||||||
<div class="column is-two-thirds">
|
<div class="column is-two-thirds">
|
||||||
<!--SPONSOR LOGO HERE-->
|
<!--SPONSOR LOGO HERE-->
|
||||||
<img src="https://odit.services/assets/img/profile-pic-no_bg.hash.0c81702a.png" width="60%" />
|
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
|
||||||
|
src="https://odit.services/assets/img/profile-pic-no_bg.hash.0c81702a.png" />
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-one-third">
|
<div class="column is-one-third">
|
||||||
<!--BARCODE HERE-->
|
<!--BARCODE HERE-->
|
||||||
<img src="https://odit.services/assets/img/profile-pic-no_bg.hash.0c81702a.png" width="100%" />
|
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
|
||||||
|
src="{{--bc this.id ../codeformat}}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>{{this.runner.lastname}}, {{this.runner.firstname}} {{this.runner.middlename}}</p>
|
<p>{{this.runner.lastname}}, {{this.runner.firstname}} {{this.runner.middlename}}</p>
|
||||||
<p>{{this.runner.group.name}} {{this.id}}</p>
|
<p>{{this.runner.group.name}}</p>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
@ -55,9 +57,12 @@
|
|||||||
<div class="columns is-multiline">
|
<div class="columns is-multiline">
|
||||||
{{#each cards_swapped}}
|
{{#each cards_swapped}}
|
||||||
<div class="column is-half runnercard">
|
<div class="column is-half runnercard">
|
||||||
<p>{{this.id}}</p>
|
|
||||||
<!--SPONSOR LOGO FIRST-->
|
<!--SPONSOR LOGO FIRST-->
|
||||||
|
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
|
||||||
|
src="https://odit.services/assets/img/profile-pic-no_bg.hash.0c81702a.png" />
|
||||||
<!--BARCODE SECOND-->
|
<!--BARCODE SECOND-->
|
||||||
|
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
|
||||||
|
src="{{--bc this.id ../codeformat}}" />
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user