pngx-pdf-viewer based on ng2-pdf-viewer with pdfjs 3.11

Squashed commit of the following:

commit 32bec8dfedbc7cbd0e2f290e1fd9ceaaa7a94366
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 12:38:19 2023 -0800

    Correctly include pdf worker js

commit 48aedbb2b9983a45ee319bc8fa1518d430c4a81b
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 08:30:53 2023 -0800

    Update angular.json

commit 23db5031632290e42e15a4eb46e2f0c72a6dadd9
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 00:43:08 2023 -0800

    Update pdf-viewer.component.ts

commit b01a18526e7df893d7ab09e491470f4bd2c3abeb
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Wed Nov 29 22:50:33 2023 -0800

    pngx-pdf-viewer based on ng2-pdf-viewer with pdfjs 3.11

    Implement zoom
This commit is contained in:
shamoon
2023-11-30 14:24:21 -08:00
parent 0ac6825154
commit e8905c1c5e
16 changed files with 2251 additions and 127 deletions

View File

@@ -19,7 +19,6 @@ import {
NgbDateStruct,
} from '@ng-bootstrap/ng-bootstrap'
import { NgSelectModule } from '@ng-select/ng-select'
import { PdfViewerComponent } from 'ng2-pdf-viewer'
import { of, throwError } from 'rxjs'
import { routes } from 'src/app/app-routing.module'
import {
@@ -70,6 +69,7 @@ import { ShareLinksDropdownComponent } from '../common/share-links-dropdown/shar
import { CustomFieldsDropdownComponent } from '../common/custom-fields-dropdown/custom-fields-dropdown.component'
import { PaperlessCustomFieldDataType } from 'src/app/data/paperless-custom-field'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { PdfViewerComponent } from '../common/pdf-viewer/pdf-viewer.component'
const doc: PaperlessDocument = {
id: 3,
@@ -160,10 +160,10 @@ describe('DocumentDetailComponent', () => {
PermissionsFormComponent,
SafeHtmlPipe,
ConfirmDialogComponent,
PdfViewerComponent,
SafeUrlPipe,
ShareLinksDropdownComponent,
CustomFieldsDropdownComponent,
PdfViewerComponent,
],
providers: [
DocumentTitlePipe,
@@ -682,6 +682,21 @@ describe('DocumentDetailComponent', () => {
expect(component.previewNumPages).toEqual(1000)
})
it('should support zoom controls', () => {
initNormally()
component.onZoomSelect({ target: { value: '1' } } as any) // from select
expect(component.previewZoomSetting).toEqual('1')
component.increaseZoom()
expect(component.previewZoomSetting).toEqual('1.5')
component.increaseZoom()
expect(component.previewZoomSetting).toEqual('2')
component.decreaseZoom()
expect(component.previewZoomSetting).toEqual('1.5')
component.onZoomSelect({ target: { value: '1' } } as any) // from select
component.decreaseZoom()
expect(component.previewZoomSetting).toEqual('.75')
})
it('should support updating notes dynamically', () => {
const notes = [
{
@@ -805,7 +820,7 @@ describe('DocumentDetailComponent', () => {
jest.spyOn(settingsService, 'get').mockReturnValue(false)
expect(component.useNativePdfViewer).toBeFalsy()
fixture.detectChanges()
expect(fixture.debugElement.query(By.css('pdf-viewer'))).not.toBeNull()
expect(fixture.debugElement.query(By.css('pngx-pdf-viewer'))).not.toBeNull()
})
it('should display native pdf viewer if enabled', () => {