Skip to content

Commit

Permalink
fix: fix vfs error
Browse files Browse the repository at this point in the history
  • Loading branch information
BayBreezy committed Sep 27, 2023
1 parent de57d79 commit 7faaf84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
9 changes: 9 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export default defineNuxtModule<ModuleOptions>({

if (!options.enabled) return;

nuxt.options.app.head.script ||= [];
nuxt.options.app.head.script.push(
{
src: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js",
},
{
src: "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.min.js",
}
);
// Add plugin
addPlugin(resolver.resolve("./runtime/pdfmake.client"));

Expand Down
16 changes: 1 addition & 15 deletions src/runtime/pdfmake.client.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import { defineNuxtPlugin } from "#app";
import * as pdfMake from "pdfmake/build/pdfmake";

export default defineNuxtPlugin(() => {
if (process.client) {
// @ts-ignore
pdfMake.fonts = {
Roboto: {
normal:
"https://cdn.jsdelivr.net/npm/typeface-roboto@1.1.13/files/roboto-latin-400.woff",
bold: "https://cdn.jsdelivr.net/npm/typeface-roboto@1.1.13/files/roboto-latin-700.woff",
italics:
"https://cdn.jsdelivr.net/npm/typeface-roboto@1.1.13/files/roboto-latin-400italic.woff",
bolditalics:
"https://cdn.jsdelivr.net/npm/typeface-roboto@1.1.13/files/roboto-latin-700italic.woff",
},
};
}
const pdfMake = window?.pdfMake as typeof import("pdfmake/build/pdfmake");
return {
provide: {
pdfMake,
Expand Down

0 comments on commit 7faaf84

Please sign in to comment.