11import { type FlatTask , type TaskStoreType } from '@/stores/tasks'
22import { type AnswerStoreType } from '@/stores/answers'
33import { FormType } from '@/models/dpia.ts'
4- import * as pdfMake from 'pdfmake/build/pdfmake'
5- import * as pdfFonts from 'pdfmake/build/vfs_fonts'
4+ import pdfMake from 'pdfmake/build/pdfmake'
5+ import pdfFonts from 'pdfmake/build/vfs_fonts'
66import type { StyleDictionary , TDocumentDefinitions , Content } from 'pdfmake/interfaces'
77import FontService from '@/services/fontService.ts'
88import { renderInstanceLabel } from '@/utils/taskUtils'
@@ -14,7 +14,8 @@ import type { CalculationStoreType } from '@/stores/calculations'
1414
1515
1616// Initialize PDFMake
17- ( < any > pdfMake ) . addVirtualFileSystem ( pdfFonts )
17+ // @ts -expect-error pdfmake 0.3.x types not yet in @types/pdfmake
18+ pdfMake . addVirtualFileSystem ( pdfFonts )
1819
1920const dutchDateFormatter = new Intl . DateTimeFormat ( 'nl-NL' , {
2021 weekday : 'long' ,
@@ -179,7 +180,12 @@ export async function exportToPdf(
179180
180181 const vfs = await FontService . getVFS ( )
181182
182- pdfMake . createPdf ( docDefinition , undefined , fontDefinitions , vfs ) . download ( actualFilename )
183+ // pdfmake 0.3: register fonts and VFS on the instance before creating PDF
184+ // @ts -expect-error pdfmake 0.3.x types not yet in @types/pdfmake
185+ pdfMake . addFonts ( fontDefinitions )
186+ // @ts -expect-error pdfmake 0.3.x types not yet in @types/pdfmake
187+ pdfMake . addVirtualFileSystem ( vfs )
188+ pdfMake . createPdf ( docDefinition ) . download ( actualFilename )
183189
184190 return Promise . resolve ( )
185191 } catch ( error ) {
0 commit comments