Skip to content

Conversation

gachimar
Copy link
Contributor

@gachimar gachimar commented Sep 8, 2022

Hi, it left a comma in the example, so i just added it to avoid problems with it.

liborm85 and others added 29 commits September 2, 2020 16:24
Using rollup as a project bundler introduces two problems with pdfmake:
1. rollup won't allow for reassigning imported module (see rollup/rollup#436), so there is no way to assign vfs fonts manually.
2. rollup won't parse vfs_fonts.js, since it uses `this` at top level, with is by default set by rollup to `undefined` (see https://rollupjs.org/guide/en/#error-this-is-undefined)

To resolve both issues, `this` for pdfmake needs to be set to `window`, with `options.moduleContext` in rollup config, and then fonts assignments needs to happen before importing pdfmake to rollup scope (fortunately, since `this` in vfs_fonts is now `window`, it will do the assignment automatically).
On macOS the shell script does not produce usable output. The `-n` is present in the resulting js file which causes the newlines to be present as well which then causes the js file to be invalid. The "oneliner" echo version with variables does work in macOS, however. (I changed the `-b` back to `-w` here)

If this also works on other OS, it might be worth to change in the example code.
Missing comma after strawberries url.
@liborm85
Copy link
Member

Thanks. Merged via 98fb40b.

@liborm85 liborm85 closed this Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants