[MNT-25541] PDFs containing JP2 images (JPEG 2000) cannot be displayed in ADW viewer (#11618)

* [MNT-25541]: adds wasmUrl to default options

* [MNT-25541]: updates UTs

* [MNT-25541]: naming change
This commit is contained in:
Anton Ramanovich
2026-02-09 11:14:38 +01:00
committed by GitHub
parent 5df193b255
commit 283b996063
3 changed files with 46 additions and 32 deletions

View File

@@ -17,36 +17,34 @@
export default {
GlobalWorkerOptions: {},
getDocument() {
return {
loadingTask: () => ({
destroy: () => Promise.resolve()
}),
promise: new Promise((resolve) => {
resolve({
numPages: 6,
getPage: () =>
Promise.resolve({
getAnnotations: () => [
{
subtype: 'Text',
name: 'NoIcon',
id: 'R13',
titleObj: {
str: 'Annotation title'
},
contentsObj: {
str: 'Annotation contents'
},
modificationDate: "D:20260202104106Z00'00",
popupRef: 'R1'
}
]
})
});
})
};
},
getDocument: jasmine.createSpy('getDocument').and.callFake(() => ({
loadingTask: () => ({
destroy: () => Promise.resolve()
}),
promise: new Promise((resolve) => {
resolve({
numPages: 6,
getPage: () =>
Promise.resolve({
getAnnotations: () => [
{
subtype: 'Text',
name: 'NoIcon',
id: 'R13',
titleObj: {
str: 'Annotation title'
},
contentsObj: {
str: 'Annotation contents'
},
modificationDate: "D:20260202104106Z00'00",
popupRef: 'R1'
}
]
})
});
})
})),
PasswordResponses: {
NEED_PASSWORD: 1,
INCORRECT_PASSWORD: 2

View File

@@ -16,7 +16,7 @@
*/
import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
import { Component, SimpleChange, ViewChild } from '@angular/core';
import { Component, SimpleChange, SimpleChanges, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog';
import { By } from '@angular/platform-browser';
@@ -514,6 +514,21 @@ describe('Test PdfViewer - User interaction', () => {
expect(component.displayPage).toBe(2);
});
it('should configure PDF.js with the correct wasmUrl', () => {
const changes: SimpleChanges = {
blobFile: new SimpleChange(null, component.blobFile, true)
};
component.ngOnChanges(changes);
const getDocumentSpy = pdfjsLibraryMock.getDocument;
expect(getDocumentSpy).toHaveBeenCalled();
const loadingArgs = getDocumentSpy.calls.mostRecent().args[0];
expect(loadingArgs.wasmUrl).toBe('./wasm/');
});
describe('Zoom', () => {
it('should zoom in increment the scale value', () => {
const zoomBefore = component.pdfViewer.currentScaleValue;

View File

@@ -148,7 +148,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
disableAutoFetch: true,
disableStream: true,
cMapUrl: './cmaps/',
cMapPacked: true
cMapPacked: true,
wasmUrl: './wasm/'
};
private pdfjsWorkerDestroy$ = new Subject<boolean>();