@@ -45,6 +45,7 @@
 | 
			
		||||
    "cors": "^2.8.5",
 | 
			
		||||
    "dotenv": "^8.2.0",
 | 
			
		||||
    "express": "^4.17.1",
 | 
			
		||||
    "handlebars": "^4.7.6",
 | 
			
		||||
    "puppeteer": "^7.0.1",
 | 
			
		||||
    "reflect-metadata": "^0.1.13",
 | 
			
		||||
    "routing-controllers": "^0.9.0-alpha.6",
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ import fs from "fs";
 | 
			
		||||
import path from 'path';
 | 
			
		||||
import puppeteer from "puppeteer";
 | 
			
		||||
import { Runner } from './models/Runner';
 | 
			
		||||
 | 
			
		||||
import Handlebars = require('handlebars');
 | 
			
		||||
/**
 | 
			
		||||
 * This class is responsible for all things pdf creation.
 | 
			
		||||
 * This uses the html templates from src/templates.
 | 
			
		||||
@@ -19,13 +19,10 @@ export class PdfCreator {
 | 
			
		||||
 | 
			
		||||
    //TODO: Accept the runner class
 | 
			
		||||
    public async generateSponsoringContract(runner: Runner): Promise<any> {
 | 
			
		||||
        let template = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8');
 | 
			
		||||
        template = template
 | 
			
		||||
            .replace("{{runner_id}}", runner.id.toString())
 | 
			
		||||
            .replace("{{runner_firstname}}", runner.firstname)
 | 
			
		||||
            .replace("{{runner_lastname}}", runner.lastname)
 | 
			
		||||
            .replace("{{runner_groupname}}", runner.group.name);
 | 
			
		||||
        return await this.renderPdf(template, { format: "A5", landscape: true });
 | 
			
		||||
        const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8');
 | 
			
		||||
        const template = Handlebars.compile(template_source);
 | 
			
		||||
        const result = template({ runner: runner })
 | 
			
		||||
        return await this.renderPdf(result, { format: "A5", landscape: true });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -6,10 +6,10 @@
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <div class="page">
 | 
			
		||||
      <p>ID: {{runner_id}}</p>
 | 
			
		||||
      <p>FIRSTNAME: {{runner_firstname}}</p>
 | 
			
		||||
      <p>LASTNAME: {{runner_lastname}}</p>
 | 
			
		||||
      <p>GROUP: {{runner_groupname}}</p>
 | 
			
		||||
      <p>ID: {{runner.id}}</p>
 | 
			
		||||
      <p>FIRSTNAME: {{runner.firstname}}</p>
 | 
			
		||||
      <p>LASTNAME: {{runner.lastname}}</p>
 | 
			
		||||
      <p>GROUP: {{runner.group.name}}</p>
 | 
			
		||||
    </div>
 | 
			
		||||
  </body>
 | 
			
		||||
</html>
 | 
			
		||||
		Reference in New Issue
	
	Block a user