pdfmake-wrapper
pdfmake-wrapper copied to clipboard
Support request for pdfmake 0.2.X
Add support for pdfmake 0.2.X
@Lugriz any chance for 0.2.x support? Or even the new 0.3.x still in beta? Is it too much work? I can see some work is already done here - can it be merged/released? https://github.com/Lugriz/pdfmake-wrapper/compare/fix-pdfmake-compatibility
@anodynos I think this project is not supported anymore. I've been using pdfmake directly lately. You don't have to change much to make it work.
Thanks, it was first attempt with it, I finally managed to make v0.2.7 play nice with typescript, so no probs 😉
@anodynos I ended up using pdfmake backend with typescript: Install dependencies
npm i pdfmake
npm i -D @types/pdfmake
Your service or equivalent:
import { createPdf, TCreatedPdf } from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
import { Content, TDocumentDefinitions } from 'pdfmake/interfaces';
export class PdfService {
public createPdf(): Promise<Buffer> {
const documentDefinitions: TDocumentDefinitions = { ... };
const pdf: TCreatedPdf = createPdf(documentDefinitions, undefined, undefined, pdfFonts.pdfMake.vfs);
const buffer: Buffer | void = await new Promise((resolve: (buffer: Buffer) => void): void => {
pdf.getBuffer((b: Buffer): void => resolve(b));
}).catch((): void => {
// currently not working since there's no way to catch errors and create a reject of the promise
// this is a problem with pdfmake
throw new InternalServerErrorException('Could not create pdf');
});
if (!buffer) {
throw new InternalServerErrorException('Could not create pdf');
}
return Buffer.from(buffer);
}
}
Thanks @Leccho ;-)
Nice to hear we can use pdfmake directly. We get the following warning currently: Warning:(55, 17) Dependency npm:pdfmake:0.1.72 is vulnerable, safe version 0.2.7 CVE-2022-46161 9.8 Improper Control of Generation of Code ('Code Injection') vulnerability with high severity found Results powered by Checkmarx(c)