diff --git a/services/web/app/views/project/editor/meta.pug b/services/web/app/views/project/editor/meta.pug index 625239dd2c..af090b1b15 100644 --- a/services/web/app/views/project/editor/meta.pug +++ b/services/web/app/views/project/editor/meta.pug @@ -14,9 +14,6 @@ meta(name="ol-wikiEnabled" data-type="boolean" content=!!(settings.apis.wiki && meta(name="ol-gitBridgePublicBaseUrl" content=gitBridgePublicBaseUrl) //- Set base path for Ace scripts loaded on demand/workers and don't use cdn meta(name="ol-aceBasePath" content="/js/" + lib('ace')) -//- Set path for PDFjs CMaps and images -meta(name="ol-pdfCMapsPath" content="/js/cmaps/") -meta(name="ol-pdfImageResourcesPath" content="/images/") //- enable doc hash checking for all projects //- used in public/js/libs/sharejs.js meta(name="ol-useShareJsHash" data-type="boolean" content=true) diff --git a/services/web/frontend/js/features/pdf-preview/util/pdf-js-versions.js b/services/web/frontend/js/features/pdf-preview/util/pdf-js-versions.js index 0399302434..11e45d4de3 100644 --- a/services/web/frontend/js/features/pdf-preview/util/pdf-js-versions.js +++ b/services/web/frontend/js/features/pdf-preview/util/pdf-js-versions.js @@ -8,6 +8,7 @@ import { createWorker } from '../../../utils/worker' async function importPDFJS210() { const cMapUrl = '/js/pdfjs-dist210/cmaps/' + const standardFontDataUrl = '/fonts/pdfjs-dist210/' const imageResourcesPath = '/images/pdfjs-dist210' const [PDFJS, PDFJSViewer] = await Promise.all([ @@ -22,11 +23,18 @@ async function importPDFJS210() { ) }) - return { PDFJS, PDFJSViewer, cMapUrl, imageResourcesPath } + return { + PDFJS, + PDFJSViewer, + cMapUrl, + imageResourcesPath, + standardFontDataUrl, + } } async function importPDFJS213() { const cMapUrl = '/js/pdfjs-dist213/cmaps/' + const standardFontDataUrl = '/fonts/pdfjs-dist213/' const imageResourcesPath = '/images/pdfjs-dist213' const [PDFJS, PDFJSViewer] = await Promise.all([ @@ -41,7 +49,13 @@ async function importPDFJS213() { ) }) - return { PDFJS, PDFJSViewer, cMapUrl, imageResourcesPath } + return { + PDFJS, + PDFJSViewer, + cMapUrl, + imageResourcesPath, + standardFontDataUrl, + } } async function importPDFJS() { diff --git a/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js b/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js index 78eb1c27ea..99fc238248 100644 --- a/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js +++ b/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js @@ -13,9 +13,13 @@ export default class PDFJSWrapper { } async init() { - const { PDFJS, PDFJSViewer, cMapUrl, imageResourcesPath } = await import( - './pdf-js-versions' - ).then(m => { + const { + PDFJS, + PDFJSViewer, + cMapUrl, + imageResourcesPath, + standardFontDataUrl, + } = await import('./pdf-js-versions').then(m => { return m.default }) @@ -23,6 +27,7 @@ export default class PDFJSWrapper { this.genPdfCachingTransport = generatePdfCachingTransportFactory(PDFJS) this.PDFJSViewer = PDFJSViewer this.cMapUrl = cMapUrl + this.standardFontDataUrl = standardFontDataUrl this.imageResourcesPath = imageResourcesPath // create the event bus @@ -78,6 +83,7 @@ export default class PDFJSWrapper { url, cMapUrl: this.cMapUrl, cMapPacked: true, + standardFontDataUrl: this.standardFontDataUrl, disableFontFace, rangeChunkSize, disableAutoFetch: true, diff --git a/services/web/webpack.config.dev.js b/services/web/webpack.config.dev.js index d4ae1c0aeb..6476454d34 100644 --- a/services/web/webpack.config.dev.js +++ b/services/web/webpack.config.dev.js @@ -73,6 +73,11 @@ module.exports = merge(base, { chunks: false, modules: false, // Hide copied assets from output - excludeAssets: [/^js\/ace/, /^js\/libs/, /^js\/cmaps/], + excludeAssets: [ + /^js\/ace/, + /^js\/libs/, + /^js\/cmaps/, + /^js\/standard_fonts/, + ], }, }) diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index 24958691d8..9f772814e6 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -304,6 +304,11 @@ module.exports = { return [ { from: `cmaps`, to: `js/${version}/cmaps`, context: dir }, + { + from: `standard_fonts`, + to: `fonts/${version}`, + context: dir, + }, { from: `legacy/web/images`, to: `images/${version}`,