mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-12 15:05:08 +00:00
Fix: include wasm assets in pdf.js-based viewer (#13122)
This commit is contained in:
@@ -79,6 +79,16 @@
|
||||
"glob": "{pdf.worker.min.mjs,pdf.min.mjs}",
|
||||
"input": "node_modules/pdfjs-dist/legacy/build/",
|
||||
"output": "/assets/js/"
|
||||
},
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "node_modules/pdfjs-dist/wasm/",
|
||||
"output": "/assets/wasm/"
|
||||
},
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "node_modules/pdfjs-dist/iccs/",
|
||||
"output": "/assets/iccs/"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
|
||||
@@ -61,6 +61,7 @@ describe('PngxPdfViewerComponent', () => {
|
||||
|
||||
it('resolves the worker source relative to the document base URI', async () => {
|
||||
setBaseHref('/paperless/')
|
||||
const getDocumentSpy = jest.spyOn(pdfjs, 'getDocument')
|
||||
|
||||
await initComponent()
|
||||
|
||||
@@ -70,6 +71,13 @@ describe('PngxPdfViewerComponent', () => {
|
||||
expect(pdfjs.GlobalWorkerOptions.workerSrc).toContain(
|
||||
'/paperless/assets/js/pdf.worker.min.mjs'
|
||||
)
|
||||
expect(getDocumentSpy).toHaveBeenCalledWith({
|
||||
url: 'test.pdf',
|
||||
password: undefined,
|
||||
withCredentials: true,
|
||||
wasmUrl: expect.stringContaining('/paperless/assets/wasm/'),
|
||||
iccUrl: expect.stringContaining('/paperless/assets/iccs/'),
|
||||
})
|
||||
})
|
||||
|
||||
it('initializes single-page viewer and disables text layer', async () => {
|
||||
|
||||
@@ -174,10 +174,12 @@ export class PngxPdfViewerComponent
|
||||
'assets/js/pdf.worker.min.mjs',
|
||||
this.document.baseURI
|
||||
).toString()
|
||||
let initOptions = {
|
||||
const initOptions = {
|
||||
url: this.src,
|
||||
password: this.password,
|
||||
withCredentials: true,
|
||||
wasmUrl: new URL('assets/wasm/', this.document.baseURI).toString(),
|
||||
iccUrl: new URL('assets/iccs/', this.document.baseURI).toString(),
|
||||
}
|
||||
this.loadingTask = getDocument(initOptions)
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user