diff --git a/src/controllers/PdfController.ts b/src/controllers/PdfController.ts index 74659f3..ab12874 100644 --- a/src/controllers/PdfController.ts +++ b/src/controllers/PdfController.ts @@ -18,7 +18,7 @@ export class PdfController { @Post('/contracts') @OpenAPI({ description: "Generate Sponsoring contract pdfs from runner objects.
You can choose your prefered locale by passing the 'locale' query-param.
If you provide more than 100 runenrs this could take a moment or two (we tested up to 1000 runners in about 70sec so far)." }) - async generateContracts(@Body({ validate: true, options: { limit: "500mb" } }) runners: Runner[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("codeformat") codeformat: string) { + async generateContracts(@Body({ validate: true, options: { limit: "500mb" } }) runners: Runner[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("codeformat") codeformat: string, @QueryParam("download") download: boolean) { if (!this.initialized) { await this.pdf.init(); this.initialized = true; @@ -29,6 +29,9 @@ export class PdfController { runners = this.mapRunnerGroupNames(runners) const contracts = await this.pdf.generateSponsoringContract(runners, locale, codeformat); res.setHeader('content-type', 'application/pdf'); + if (download) { + res.setHeader('Content-Disposition', 'attachment; filename="contracts.pdf"') + } return contracts; }