Skip to content

Commit

Permalink
Bundle pdfjs fonts (#49)
Browse files Browse the repository at this point in the history
* Bundle pdfjs fonts

* Bundled PDFJS Cmaps and Fonts
- Cmaps and standard fonts now provided in package
as PDFJS requires local path to these items not provided in pkg
- Remove bundling in pkg
  • Loading branch information
Lucky38i authored Oct 15, 2022
1 parent d5f1765 commit 19b0be3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/server/src/utilities/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ export class FileService {

async getConvertedPdfFile(fileName: string, pageNumber: number, scale: number = 4): Promise<StreamableFile> {
// Some PDFs need external cmaps.
const CMAP_URL = '../../../node_modules/pdfjs-dist/cmaps/';
const CMAP_URL = `${join(process.cwd(), 'node_modules', 'pdfjs-dist', 'cmaps')}/`;
const CMAP_PACKED = true;

// Where the standard fonts are located.
const STANDARD_FONT_DATA_URL = '../../../node_modules/pdfjs-dist/standard_fonts/';
const STANDARD_FONT_DATA_URL = `${join(process.cwd(), 'node_modules', 'pdfjs-dist', 'standard_fonts')}/`;

try {
const conversionFilePath = join(process.cwd(), 'resources', 'pdfs', fileName);
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"copy:resources": "copyfiles -s -f apps/server/src/config/properties.json ./node_modules/pdf-to-printer/dist/SumatraPDF.exe build/resources",
"copy:modules": "npm run copy:traybin && npm run copy:pdfjs && npm run copy:nodehide && npm run copy:sharp && npm run copy:open",
"copy:traybin": "copyfiles -s -f ./node_modules/systray2/traybin/tray_windows_release.exe build/traybin",
"copy:pdfjs": "copyfiles -s -f \"node_modules/pdfjs-dist/build/**/*.*\" build/node_modules/pdfjs-dist/build",
"copy:pdfjs": "copyfiles -s -f \"node_modules/pdfjs-dist/build/**/*.*\" build/node_modules/pdfjs-dist/build && npm run copy:pdfjs:fonts && npm run copy:pdfjs:cmaps",
"copy:pdfjs:fonts": "copyfiles -s -f \"node_modules/pdfjs-dist/standard_fonts/**/*.*\" build/node_modules/pdfjs-dist/standard_fonts",
"copy:pdfjs:cmaps": "copyfiles -s -f \"node_modules/pdfjs-dist/cmaps/**/*.*\" build/node_modules/pdfjs-dist/cmaps",
"copy:nodehide": "copyfiles -s -f \"node_modules/node-hide-console-window/build/Release/**/*\" build/node_modules/node-hide-console-window/build/Release",
"copy:sharp": "copyfiles -s -f \"node_modules/sharp/build/Release/**/*\" build/node_modules/sharp/build/Release",
"copy:open": "copyfiles -s -f \"node_modules/open/xdg-open\" build/node_modules/open",
Expand Down

0 comments on commit 19b0be3

Please sign in to comment.