Skip to content

Commit

Permalink
changed Virtual file system (VFS) format for better compatibility wit…
Browse files Browse the repository at this point in the history
…h frameworks
  • Loading branch information
liborm85 committed Nov 1, 2024
1 parent 4e87757 commit e420106
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Added support PDF/A and PDF/UA
- Changed Virtual file system (VFS) format for better compatibility with frameworks (backwards compatibility preserved). **For compatibility with frameworks, rebuild VFS required!**
- Update pdfkit to 0.15.1
- Fixed bug with how page breaks provoked by cells with rowspan were handled
- Fixed find where previous cell started with row span and col span combination
Expand Down
4 changes: 2 additions & 2 deletions build-vfs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');

const vfsBefore = "this.pdfMake = this.pdfMake || {}; this.pdfMake.vfs = ";
const vfsAfter = ";";
const vfsBefore = "var vfs = ";
const vfsAfter = "; var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this; if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addVirtualFileSystem !== 'undefined') { _global.pdfMake.addVirtualFileSystem(vfs); } if (typeof module !== 'undefined') { module.exports = vfs; }";
const sourcePath = process.argv[2];
const vfsFilename = process.argv[3] ? process.argv[3] : './build/vfs_fonts.js';

Expand Down
4 changes: 2 additions & 2 deletions build/vfs_fonts.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/browser-extensions/pdfMake.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var defaultClientFonts = {
}
};

var globalVfs;

function Document(docDefinition, tableLayouts, fonts, vfs) {
this.docDefinition = docDefinition;
this.tableLayouts = tableLayouts || null;
Expand Down Expand Up @@ -323,7 +325,10 @@ module.exports = {
docDefinition,
tableLayouts || global.pdfMake.tableLayouts,
fonts || global.pdfMake.fonts,
vfs || global.pdfMake.vfs
vfs || globalVfs || global.pdfMake.vfs
);
},
addVirtualFileSystem: function (vfs) {
globalVfs = vfs;
}
};

0 comments on commit e420106

Please sign in to comment.