Skip to content

Commit

Permalink
fix: export properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-humann committed Aug 23, 2023
1 parent dddb2d9 commit 893436c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pdf/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as puppeteer from 'puppeteer-core';
import chalk from 'chalk';
import { getOutline, setOutline } from './outline';
import { PDFDocument } from 'pdf-lib';
import { writeFileSync } from 'fs';

export interface PDFOptions {
outputPDFFilename: string;
Expand Down Expand Up @@ -61,7 +62,8 @@ export class PDF {
});
const pdfDoc = await PDFDocument.load(pdf);
setOutline(pdfDoc, outline, true);
pdfDoc.save();
const buffer = await pdfDoc.save();
writeFileSync(this.options.outputPDFFilename ?? 'output.pdf', buffer);
console.log(
chalk.green(`PDF generated at ${this.options.outputPDFFilename ?? 'output.pdf'}`),
);
Expand Down

0 comments on commit 893436c

Please sign in to comment.