Skip to content

Commit 464e6ea

Browse files
committed
Adding the pdfMake error fix
1 parent f110450 commit 464e6ea

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

front-end/src/views/MaterialsView.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import Bell from '@/components/common/svg/Bell.vue';
7878
import ApprouvalCenter from '@/components/materials/ApprouvalCenter.vue';
7979
import { useMaterialStore } from '@/store/modules/material.store';
8080
import { useRouter } from 'vue-router';
81+
import pdfMakeFonts from '@/utils/pdfMakeFonts';
8182
8283
// This file will register globalThis.pdfMake.vfs, the documentation does not explicity define the behavior
8384
// Unless you want to change the font, you don't need to assign pdfmake.vfs = globalThis.pdfMake.vfs.

front-end/src/views/material-ideas/DraftPdf.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
</template>
2424

2525
<script>
26-
import pdfMake from 'pdfmake/build/pdfmake';
27-
import pdfFonts from 'pdfmake/build/vfs_fonts';
26+
// import pdfMake from 'pdfmake/build/pdfmake';
27+
// import pdfFonts from 'pdfmake/build/vfs_fonts';
2828
import CodingToolsLogo from '@/assets/images/CodingToolsLogo.png';
2929
import { useUserStore } from '@/store/modules/user.store';
3030
import { computed } from 'vue';
@@ -37,7 +37,9 @@ const userStore = useUserStore();
3737
const user = computed(() => authStore.user);
3838
const userId = computed(() => user.value._id);
3939
40-
pdfMake.vfs = pdfFonts.pdfMake.vfs;
40+
import { createPdf } from 'pdfmake/build/pdfmake';
41+
import * as _ from 'pdfmake/build/vfs_fonts.js';
42+
const fonts = globalThis.pdfMake.vfs ?? _.pdfMake.vfs;
4143
4244
const date = new Date().toLocaleDateString();
4345
let base64Image = null;
@@ -118,7 +120,7 @@ export default {
118120
},
119121
},
120122
};
121-
pdfMake.createPdf(docDefinition).download(`devis_${this.item.title}`);
123+
createPdf(docDefinition, null, null, fonts).download(`devis_${this.item.title}`);
122124
},
123125
},
124126
};

front-end/src/views/material-ideas/IdeasPdf.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
</template>
2626

2727
<script>
28-
import pdfMake from 'pdfmake/build/pdfmake';
29-
import pdfFonts from 'pdfmake/build/vfs_fonts';
28+
// import pdfMake from 'pdfmake/build/pdfmake';
29+
// import pdfFonts from 'pdfmake/build/vfs_fonts';
3030
import CodingToolsLogo from '@/assets/images/CodingToolsLogo.png';
3131
import { useUserStore } from '@/store/modules/user.store';
3232
import { computed } from 'vue';
@@ -39,7 +39,10 @@ const userStore = useUserStore();
3939
const user = computed(() => authStore.user);
4040
const userId = computed(() => user.value._id);
4141
42-
pdfMake.vfs = pdfFonts.pdfMake.vfs;
42+
import { createPdf } from 'pdfmake/build/pdfmake';
43+
import * as _ from 'pdfmake/build/vfs_fonts.js';
44+
const fonts = globalThis.pdfMake.vfs ?? _.pdfMake.vfs;
45+
4346
4447
const date = new Date().toLocaleDateString();
4548
let base64Image = null;
@@ -125,7 +128,7 @@ export default {
125128
},
126129
};
127130
console.log(docDefinition);
128-
pdfMake.createPdf(docDefinition).download(`Suggestions_equipement`);
131+
createPdf(docDefinition, null, null, fonts).download(`Suggestions_equipement`);
129132
},
130133
},
131134
};

0 commit comments

Comments
 (0)