update other packages and pdftron
This commit is contained in:
parent
2d0f6e4c48
commit
f40c67337a
@ -5,9 +5,8 @@ import { AppStateService } from '@state/app-state.service';
|
||||
import { environment } from '@environments/environment';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Debounce, IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
||||
import { Debounce, IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { WatermarkControllerService, WatermarkModelRes } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { BASE_HREF } from '../../../../tokens';
|
||||
import { stampPDFPage } from '@utils/page-stamper';
|
||||
@ -137,7 +136,7 @@ export class WatermarkScreenComponent implements OnInit {
|
||||
).then(instance => {
|
||||
this._instance = instance;
|
||||
|
||||
instance.docViewer.on('documentLoaded', async () => {
|
||||
instance.Core.documentViewer.on('documentLoaded', async () => {
|
||||
this._loadingService.stop();
|
||||
await this._drawWatermark();
|
||||
});
|
||||
@ -149,19 +148,19 @@ export class WatermarkScreenComponent implements OnInit {
|
||||
responseType: 'blob'
|
||||
})
|
||||
.subscribe(blobData => {
|
||||
this._instance.loadDocument(blobData, { filename: 'blank.pdf' });
|
||||
this._instance.UI.loadDocument(blobData, { filename: 'blank.pdf' });
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _disableElements() {
|
||||
this._instance.disableElements(['header', 'toolsHeader', 'pageNavOverlay', 'textPopup']);
|
||||
this._instance.UI.disableElements(['header', 'toolsHeader', 'pageNavOverlay', 'textPopup']);
|
||||
}
|
||||
|
||||
private async _drawWatermark() {
|
||||
const pdfNet = this._instance.PDFNet;
|
||||
const document = await this._instance.docViewer.getDocument().getPDFDoc();
|
||||
const pdfNet = this._instance.Core.PDFNet;
|
||||
const document = await this._instance.Core.documentViewer.getDocument().getPDFDoc();
|
||||
|
||||
const text = this.configForm.get('text').value || '';
|
||||
const fontSize = this.configForm.get('fontSize').value;
|
||||
@ -171,8 +170,8 @@ export class WatermarkScreenComponent implements OnInit {
|
||||
const color = this.configForm.get('hexColor').value;
|
||||
|
||||
await stampPDFPage(document, pdfNet, text, fontSize, fontType, orientation, opacity, color, [1]);
|
||||
this._instance.docViewer.refreshAll();
|
||||
this._instance.docViewer.updateView([0], 0);
|
||||
this._instance.Core.documentViewer.refreshAll();
|
||||
this._instance.Core.documentViewer.updateView([0], 0);
|
||||
this._changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,8 @@ export class AnnotationActionsComponent implements OnInit {
|
||||
}
|
||||
|
||||
get viewerAnnotations() {
|
||||
if (this.viewer?.annotManager) {
|
||||
return this._annotations.map(a => this.viewer?.annotManager?.getAnnotationById(a.id));
|
||||
if (this.viewer?.Core.annotationManager) {
|
||||
return this._annotations.map(a => this.viewer?.Core.annotationManager?.getAnnotationById(a.id));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
@ -78,15 +78,15 @@ export class AnnotationActionsComponent implements OnInit {
|
||||
|
||||
hideAnnotation($event: MouseEvent) {
|
||||
$event.stopPropagation();
|
||||
this.viewer.annotManager.hideAnnotations(this.viewerAnnotations);
|
||||
this.viewer.annotManager.deselectAllAnnotations();
|
||||
this.viewer.Core.annotationManager.hideAnnotations(this.viewerAnnotations);
|
||||
this.viewer.Core.annotationManager.deselectAllAnnotations();
|
||||
this.annotationActionsService.updateHiddenAnnotation(this.annotations, this.viewerAnnotations, true);
|
||||
}
|
||||
|
||||
showAnnotation($event: MouseEvent) {
|
||||
$event.stopPropagation();
|
||||
this.viewer.annotManager.showAnnotations(this.viewerAnnotations);
|
||||
this.viewer.annotManager.deselectAllAnnotations();
|
||||
this.viewer.Core.annotationManager.showAnnotations(this.viewerAnnotations);
|
||||
this.viewer.Core.annotationManager.deselectAllAnnotations();
|
||||
this.annotationActionsService.updateHiddenAnnotation(this.annotations, this.viewerAnnotations, false);
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import {
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { ManualRedactionEntry } from '@redaction/red-ui-http';
|
||||
import WebViewer, { Annotations, Tools, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import WebViewer, { Core, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
@ -23,7 +23,7 @@ import { AnnotationDrawService } from '../../services/annotation-draw.service';
|
||||
import { AnnotationActionsService } from '../../services/annotation-actions.service';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { BASE_HREF } from '../../../../tokens';
|
||||
import { AppConfigKey, AppConfigService } from '../../../app-config/app-config.service';
|
||||
import { AppConfigKey, AppConfigService } from '@app-config/app-config.service';
|
||||
import { LoadingService } from '@iqser/common-ui';
|
||||
import { DossiersDialogService } from '../../services/dossiers-dialog.service';
|
||||
import { ConfirmationDialogInput } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component';
|
||||
@ -33,6 +33,8 @@ import { ViewMode } from '@models/file/view-mode';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import TextTool = Tools.TextTool;
|
||||
import Tools = Core.Tools;
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-pdf-viewer',
|
||||
@ -107,11 +109,11 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
setInitialViewerState() {
|
||||
// viewer init
|
||||
this.instance.setFitMode('FitPage');
|
||||
this.instance.UI.setFitMode('FitPage');
|
||||
|
||||
const instanceDisplayMode = this.instance.docViewer.getDisplayModeManager().getDisplayMode();
|
||||
const instanceDisplayMode = this.instance.Core.documentViewer.getDisplayModeManager().getDisplayMode();
|
||||
instanceDisplayMode.mode = this.viewMode === 'STANDARD' ? 'Single' : 'Facing';
|
||||
this.instance.docViewer.getDisplayModeManager().setDisplayMode(instanceDisplayMode);
|
||||
this.instance.Core.documentViewer.getDisplayModeManager().setDisplayMode(instanceDisplayMode);
|
||||
}
|
||||
|
||||
async uploadFile(files: any) {
|
||||
@ -123,13 +125,13 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
if (fileToCompare) {
|
||||
fileReader.onload = async () => {
|
||||
const pdfData = fileReader.result;
|
||||
const pdfNet = this.instance.Core.PDFNet;
|
||||
|
||||
const PDFNet = this.instance.PDFNet;
|
||||
await PDFNet.initialize(environment.licenseKey ? atob(environment.licenseKey) : null);
|
||||
await pdfNet.initialize(environment.licenseKey ? atob(environment.licenseKey) : null);
|
||||
|
||||
const mergedDocument = await PDFNet.PDFDoc.create();
|
||||
const compareDocument = await PDFNet.PDFDoc.createFromBuffer(<any>pdfData);
|
||||
const currentDocument = await PDFNet.PDFDoc.createFromBuffer(await this.fileData.arrayBuffer());
|
||||
const mergedDocument = await pdfNet.PDFDoc.create();
|
||||
const compareDocument = await pdfNet.PDFDoc.createFromBuffer(<any>pdfData);
|
||||
const currentDocument = await pdfNet.PDFDoc.createFromBuffer(await this.fileData.arrayBuffer());
|
||||
|
||||
const currentDocumentPageCount = await currentDocument.getPageCount();
|
||||
const compareDocumentPageCount = await compareDocument.getPageCount();
|
||||
@ -151,7 +153,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
() => {
|
||||
this.utils.navigateToPage(1);
|
||||
},
|
||||
PDFNet
|
||||
this.instance.Core.PDFNet
|
||||
);
|
||||
this._loadingService.stop();
|
||||
};
|
||||
@ -182,14 +184,14 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
async closeCompareMode() {
|
||||
this.viewMode = 'STANDARD';
|
||||
const PDFNet = this.instance.PDFNet;
|
||||
await PDFNet.initialize(environment.licenseKey ? atob(environment.licenseKey) : null);
|
||||
const currentDocument = await PDFNet.PDFDoc.createFromBuffer(await this.fileData.arrayBuffer());
|
||||
this.instance.loadDocument(currentDocument, {
|
||||
const pdfNet = this.instance.Core.PDFNet;
|
||||
await pdfNet.initialize(environment.licenseKey ? atob(environment.licenseKey) : null);
|
||||
const currentDocument = await pdfNet.PDFDoc.createFromBuffer(await this.fileData.arrayBuffer());
|
||||
this.instance.UI.loadDocument(currentDocument, {
|
||||
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
|
||||
});
|
||||
this.instance.disableElements(['closeCompareButton']);
|
||||
this.instance.enableElements(['compareButton']);
|
||||
this.instance.UI.disableElements(['closeCompareButton']);
|
||||
this.instance.UI.enableElements(['compareButton']);
|
||||
this.utils.navigateToPage(1);
|
||||
}
|
||||
|
||||
@ -216,8 +218,8 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
this.utils.disableHotkeys();
|
||||
this._configureTextPopup();
|
||||
|
||||
this.instance.annotManager.on('annotationSelected', (annotations, action) => {
|
||||
this.annotationSelected.emit(this.instance.annotManager.getSelectedAnnotations().map(ann => ann.Id));
|
||||
this.instance.Core.annotationManager.on('annotationSelected', (annotations, action) => {
|
||||
this.annotationSelected.emit(this.instance.Core.annotationManager.getSelectedAnnotations().map(ann => ann.Id));
|
||||
if (action === 'deselected') {
|
||||
this._toggleRectangleAnnotationAction(true);
|
||||
} else {
|
||||
@ -226,16 +228,16 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.annotManager.on('annotationChanged', annotations => {
|
||||
this.instance.Core.annotationManager.on('annotationChanged', annotations => {
|
||||
// when a rectangle is drawn,
|
||||
// it returns one annotation with tool name 'AnnotationCreateRectangle;
|
||||
// this will auto select rectangle after drawing
|
||||
if (annotations.length === 1 && annotations[0].ToolName === 'AnnotationCreateRectangle') {
|
||||
this.instance.annotManager.selectAnnotations(annotations);
|
||||
this.instance.Core.annotationManager.selectAnnotations(annotations);
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.docViewer.on('pageNumberUpdated', pageNumber => {
|
||||
this.instance.Core.documentViewer.on('pageNumberUpdated', pageNumber => {
|
||||
if (this.shouldDeselectAnnotationsOnPageChange) {
|
||||
this.utils.deselectAllAnnotations();
|
||||
}
|
||||
@ -250,9 +252,9 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.docViewer.on('documentLoaded', this._documentLoaded);
|
||||
this.instance.Core.documentViewer.on('documentLoaded', this._documentLoaded);
|
||||
|
||||
this.instance.docViewer.on('keyUp', $event => {
|
||||
this.instance.Core.documentViewer.on('keyUp', $event => {
|
||||
// arrows and full-screen
|
||||
if ($event.target?.tagName?.toLowerCase() !== 'input') {
|
||||
if ($event.key.startsWith('Arrow') || $event.key === 'f') {
|
||||
@ -270,23 +272,23 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.docViewer.on('textSelected', (quads, selectedText) => {
|
||||
this.instance.Core.documentViewer.on('textSelected', (quads, selectedText) => {
|
||||
this._selectedText = selectedText;
|
||||
if (selectedText.length > 2 && this.canPerformActions) {
|
||||
this.instance.enableElements(['add-dictionary', 'add-false-positive']);
|
||||
this.instance.UI.enableElements(['add-dictionary', 'add-false-positive']);
|
||||
} else {
|
||||
this.instance.disableElements(['add-dictionary', 'add-false-positive']);
|
||||
this.instance.UI.disableElements(['add-dictionary', 'add-false-positive']);
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.iframeWindow.addEventListener('visibilityChanged', (event: any) => {
|
||||
this.instance.UI.iframeWindow.addEventListener('visibilityChanged', (event: any) => {
|
||||
if (event.detail.element === 'searchPanel') {
|
||||
const inputElement = this.instance.iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement;
|
||||
const inputElement = this.instance.UI.iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement;
|
||||
setTimeout(() => {
|
||||
inputElement.value = '';
|
||||
}, 0);
|
||||
if (!event.detail.isVisible) {
|
||||
this.instance.docViewer.clearSearchResults();
|
||||
this.instance.Core.documentViewer.clearSearchResults();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -295,20 +297,20 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private _setSelectionMode(): void {
|
||||
const textTool = (<unknown>this.instance.Tools.TextTool) as TextTool;
|
||||
const textTool = (<unknown>this.instance.Core.Tools.TextTool) as TextTool;
|
||||
textTool.SELECTION_MODE = this._appConfigService.getConfig(AppConfigKey.SELECTION_MODE);
|
||||
}
|
||||
|
||||
private _toggleRectangleAnnotationAction(readonly: boolean) {
|
||||
if (!readonly) {
|
||||
this.instance.enableElements(['add-rectangle']);
|
||||
this.instance.UI.enableElements(['add-rectangle']);
|
||||
} else {
|
||||
this.instance.disableElements(['add-rectangle']);
|
||||
this.instance.UI.disableElements(['add-rectangle']);
|
||||
}
|
||||
}
|
||||
|
||||
private _disableElements() {
|
||||
this.instance.disableElements([
|
||||
this.instance.UI.disableElements([
|
||||
'pageNavOverlay',
|
||||
'menuButton',
|
||||
'selectToolButton',
|
||||
@ -331,7 +333,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
'annotationGroupButton'
|
||||
]);
|
||||
|
||||
this.instance.setHeaderItems(header => {
|
||||
this.instance.UI.setHeaderItems(header => {
|
||||
const originalHeaderItems = header.getItems();
|
||||
originalHeaderItems.splice(8, 0, {
|
||||
type: 'divider',
|
||||
@ -372,9 +374,9 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.disableElements(['closeCompareButton']);
|
||||
this.instance.UI.disableElements(['closeCompareButton']);
|
||||
|
||||
this.instance.docViewer.getTool('AnnotationCreateRectangle').setStyles(() => ({
|
||||
this.instance.Core.documentViewer.getTool('AnnotationCreateRectangle').setStyles(() => ({
|
||||
StrokeThickness: 2,
|
||||
StrokeColor: this._annotationDrawService.getColor(this.instance, 'manual'),
|
||||
FillColor: this._annotationDrawService.getColor(this.instance, 'manual'),
|
||||
@ -382,13 +384,13 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}));
|
||||
}
|
||||
|
||||
private _configureAnnotationSpecificActions(viewerAnnotations: Annotations.Annotation[]) {
|
||||
private _configureAnnotationSpecificActions(viewerAnnotations: Annotation[]) {
|
||||
if (!this.canPerformActions) {
|
||||
return;
|
||||
}
|
||||
|
||||
const annotationWrappers = viewerAnnotations.map(va => this.annotations.find(a => a.id === va.Id)).filter(va => !!va);
|
||||
this.instance.annotationPopup.update([]);
|
||||
this.instance.UI.annotationPopup.update([]);
|
||||
|
||||
if (annotationWrappers.length === 0) {
|
||||
this._configureRectangleAnnotationPopup();
|
||||
@ -400,7 +402,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
if (allAnnotationsHaveImageAction) {
|
||||
const allAreVisible = viewerAnnotations.reduce((acc, next) => next.isVisible() && acc, true);
|
||||
|
||||
this.instance.annotationPopup.add([
|
||||
this.instance.UI.annotationPopup.add([
|
||||
{
|
||||
type: 'actionButton',
|
||||
img: allAreVisible
|
||||
@ -410,11 +412,11 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
onClick: () => {
|
||||
this._ngZone.run(() => {
|
||||
if (allAreVisible) {
|
||||
this.instance.annotManager.hideAnnotations(viewerAnnotations);
|
||||
this.instance.Core.annotationManager.hideAnnotations(viewerAnnotations);
|
||||
} else {
|
||||
this.instance.annotManager.showAnnotations(viewerAnnotations);
|
||||
this.instance.Core.annotationManager.showAnnotations(viewerAnnotations);
|
||||
}
|
||||
this.instance.annotManager.deselectAllAnnotations();
|
||||
this.instance.Core.annotationManager.deselectAllAnnotations();
|
||||
this._annotationActionsService.updateHiddenAnnotation(this.annotations, viewerAnnotations, allAreVisible);
|
||||
});
|
||||
}
|
||||
@ -422,19 +424,19 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
]);
|
||||
}
|
||||
|
||||
this.instance.annotationPopup.add(
|
||||
this.instance.UI.annotationPopup.add(
|
||||
this._annotationActionsService.getViewerAvailableActions(annotationWrappers, this.annotationsChanged)
|
||||
);
|
||||
}
|
||||
|
||||
private _configureRectangleAnnotationPopup() {
|
||||
this.instance.annotationPopup.add(<any>{
|
||||
this.instance.UI.annotationPopup.add(<any>{
|
||||
type: 'actionButton',
|
||||
dataElement: 'add-rectangle',
|
||||
img: this._convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'),
|
||||
title: this._translateService.instant(this._manualAnnotationService.getTitle('REDACTION')),
|
||||
onClick: () => {
|
||||
const selectedAnnotations = this.instance.annotManager.getSelectedAnnotations();
|
||||
const selectedAnnotations = this.instance.Core.annotationManager.getSelectedAnnotations();
|
||||
const activeAnnotation = selectedAnnotations[0];
|
||||
const activePage = selectedAnnotations[0].getPageNumber();
|
||||
const quad = this._annotationDrawService.annotationToQuads(activeAnnotation, this.instance);
|
||||
@ -443,8 +445,8 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
const mre = this._getManualRedactionEntry(quadsObject, 'Rectangle');
|
||||
// cleanup selection and button state
|
||||
this.utils.deselectAllAnnotations();
|
||||
this.instance.disableElements(['shapeToolGroupButton', 'rectangleToolDivider']);
|
||||
this.instance.enableElements(['shapeToolGroupButton', 'rectangleToolDivider']);
|
||||
this.instance.UI.disableElements(['shapeToolGroupButton', 'rectangleToolDivider']);
|
||||
this.instance.UI.enableElements(['shapeToolGroupButton', 'rectangleToolDivider']);
|
||||
// dispatch event
|
||||
this.manualAnnotationRequested.emit(
|
||||
new ManualRedactionEntryWrapper([quad], mre, 'REDACTION', 'RECTANGLE', activeAnnotation.Id)
|
||||
@ -454,12 +456,12 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private _configureTextPopup() {
|
||||
this.instance.textPopup.add(<any>{
|
||||
this.instance.UI.textPopup.add(<any>{
|
||||
type: 'actionButton',
|
||||
img: this._convertPath('/assets/icons/general/pdftron-action-search.svg'),
|
||||
title: this._translateService.instant('pdf-viewer.text-popup.actions.search'),
|
||||
onClick: () => {
|
||||
const text = this.instance.docViewer.getSelectedText();
|
||||
const text = this.instance.Core.documentViewer.getSelectedText();
|
||||
const searchOptions = {
|
||||
caseSensitive: true, // match case
|
||||
wholeWord: true, // match whole words only
|
||||
@ -468,57 +470,57 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
searchUp: false, // search from the end of the document upwards
|
||||
ambientString: true // return ambient string as part of the result
|
||||
};
|
||||
this.instance.openElements(['searchPanel']);
|
||||
this.instance.UI.openElements(['searchPanel']);
|
||||
setTimeout(() => {
|
||||
this.instance.searchTextFull(text, searchOptions);
|
||||
this.instance.UI.searchTextFull(text, searchOptions);
|
||||
}, 250);
|
||||
}
|
||||
});
|
||||
|
||||
// Adding directly to the false-positive dict is only available in dev-mode
|
||||
if (this._userPreferenceService.areDevFeaturesEnabled) {
|
||||
this.instance.textPopup.add(<any>{
|
||||
this.instance.UI.textPopup.add(<any>{
|
||||
type: 'actionButton',
|
||||
dataElement: 'add-false-positive',
|
||||
img: this._convertPath('/assets/icons/general/pdftron-action-false-positive.svg'),
|
||||
title: this._translateService.instant(this._manualAnnotationService.getTitle('FALSE_POSITIVE')),
|
||||
onClick: () => {
|
||||
const selectedQuads = this.instance.docViewer.getSelectedTextQuads();
|
||||
const text = this.instance.docViewer.getSelectedText();
|
||||
const selectedQuads = this.instance.Core.documentViewer.getSelectedTextQuads();
|
||||
const text = this.instance.Core.documentViewer.getSelectedText();
|
||||
const mre = this._getManualRedactionEntry(selectedQuads, text, true);
|
||||
this.manualAnnotationRequested.emit(
|
||||
new ManualRedactionEntryWrapper(this.instance.docViewer.getSelectedTextQuads(), mre, 'FALSE_POSITIVE')
|
||||
new ManualRedactionEntryWrapper(this.instance.Core.documentViewer.getSelectedTextQuads(), mre, 'FALSE_POSITIVE')
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.instance.textPopup.add(<any>{
|
||||
this.instance.UI.textPopup.add(<any>{
|
||||
type: 'actionButton',
|
||||
dataElement: 'add-dictionary',
|
||||
img: this._convertPath('/assets/icons/general/pdftron-action-add-dict.svg'),
|
||||
title: this._translateService.instant(this._manualAnnotationService.getTitle('DICTIONARY')),
|
||||
onClick: () => {
|
||||
const selectedQuads = this.instance.docViewer.getSelectedTextQuads();
|
||||
const text = this.instance.docViewer.getSelectedText();
|
||||
const selectedQuads = this.instance.Core.documentViewer.getSelectedTextQuads();
|
||||
const text = this.instance.Core.documentViewer.getSelectedText();
|
||||
const mre = this._getManualRedactionEntry(selectedQuads, text, true);
|
||||
this.manualAnnotationRequested.emit(
|
||||
new ManualRedactionEntryWrapper(this.instance.docViewer.getSelectedTextQuads(), mre, 'DICTIONARY')
|
||||
new ManualRedactionEntryWrapper(this.instance.Core.documentViewer.getSelectedTextQuads(), mre, 'DICTIONARY')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
this.instance.textPopup.add(<any>{
|
||||
this.instance.UI.textPopup.add(<any>{
|
||||
type: 'actionButton',
|
||||
dataElement: 'add-redaction',
|
||||
img: this._convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'),
|
||||
title: this._translateService.instant(this._manualAnnotationService.getTitle('REDACTION')),
|
||||
onClick: () => {
|
||||
const selectedQuads = this.instance.docViewer.getSelectedTextQuads();
|
||||
const text = this.instance.docViewer.getSelectedText();
|
||||
const selectedQuads = this.instance.Core.documentViewer.getSelectedTextQuads();
|
||||
const text = this.instance.Core.documentViewer.getSelectedText();
|
||||
const mre = this._getManualRedactionEntry(selectedQuads, text, true);
|
||||
this.manualAnnotationRequested.emit(
|
||||
new ManualRedactionEntryWrapper(this.instance.docViewer.getSelectedTextQuads(), mre, 'REDACTION')
|
||||
new ManualRedactionEntryWrapper(this.instance.Core.documentViewer.getSelectedTextQuads(), mre, 'REDACTION')
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -526,10 +528,10 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private _handleCustomActions() {
|
||||
this.instance.setToolMode('AnnotationEdit');
|
||||
this.instance.UI.setToolMode('AnnotationEdit');
|
||||
if (this.canPerformActions) {
|
||||
this.instance.enableTools(['AnnotationCreateRectangle']);
|
||||
this.instance.enableElements([
|
||||
this.instance.UI.enableTools(['AnnotationCreateRectangle']);
|
||||
this.instance.UI.enableElements([
|
||||
'add-redaction',
|
||||
'add-rectangle',
|
||||
'add-false-positive',
|
||||
@ -538,11 +540,11 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
'annotationPopup'
|
||||
]);
|
||||
if (this._selectedText.length > 2) {
|
||||
this.instance.enableElements(['add-dictionary', 'add-false-positive']);
|
||||
this.instance.UI.enableElements(['add-dictionary', 'add-false-positive']);
|
||||
}
|
||||
} else {
|
||||
this.instance.disableTools(['AnnotationCreateRectangle']);
|
||||
this.instance.disableElements([
|
||||
this.instance.UI.disableTools(['AnnotationCreateRectangle']);
|
||||
this.instance.UI.disableElements([
|
||||
'add-redaction',
|
||||
'add-dictionary',
|
||||
'add-false-positive',
|
||||
@ -568,7 +570,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
private _loadDocument() {
|
||||
if (this.fileData) {
|
||||
this.instance.loadDocument(this.fileData, {
|
||||
this.instance.UI.loadDocument(this.fileData, {
|
||||
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ChangeDetectorRef, Component, HostListener, NgZone, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, ActivatedRouteSnapshot, NavigationExtras, Router } from '@angular/router';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import { Core, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import { PdfViewerComponent } from '../../components/pdf-viewer/pdf-viewer.component';
|
||||
import {
|
||||
AutoUnsubscribe,
|
||||
@ -43,6 +43,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { fileStatusTranslations } from '../../translations/file-status-translations';
|
||||
import { handleFilterDelta } from '@utils/filter-utils';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f'];
|
||||
|
||||
@ -131,7 +132,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
get activeViewerPage(): number {
|
||||
const currentPage = this._instance?.docViewer?.getCurrentPage();
|
||||
const currentPage = this._instance?.Core.documentViewer?.getCurrentPage();
|
||||
if (!currentPage) {
|
||||
return 0;
|
||||
}
|
||||
@ -262,9 +263,9 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
rebuildFilters(deletePreviousAnnotations = false): void {
|
||||
const startTime = new Date().getTime();
|
||||
if (deletePreviousAnnotations) {
|
||||
const annotationsToDelete = this._instance?.annotManager?.getAnnotationsList() || [];
|
||||
const annotationsToDelete = this._instance?.Core.annotationManager?.getAnnotationsList() || [];
|
||||
try {
|
||||
this._instance?.annotManager?.deleteAnnotations(annotationsToDelete, {
|
||||
this._instance?.Core.annotationManager?.deleteAnnotations(annotationsToDelete, {
|
||||
imported: true,
|
||||
force: true
|
||||
});
|
||||
@ -344,8 +345,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
entryWrapper,
|
||||
async (response: ManualAnnotationResponse) => {
|
||||
if (response?.annotationId) {
|
||||
const annotation = this._instance.annotManager.getAnnotationById(response.manualRedactionEntryWrapper.rectId);
|
||||
this._instance.annotManager.deleteAnnotation(annotation);
|
||||
const annotation = this._instance.Core.annotationManager.getAnnotationById(
|
||||
response.manualRedactionEntryWrapper.rectId
|
||||
);
|
||||
this._instance.Core.annotationManager.deleteAnnotation(annotation);
|
||||
this.fileData.fileStatus = await this.appStateService.reloadActiveFile();
|
||||
const distinctPages = entryWrapper.manualRedactionEntry.positions
|
||||
.map(p => p.page)
|
||||
@ -550,11 +553,12 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
|
||||
private async _doStampExcludedPages(excludedPages: number[]) {
|
||||
if (excludedPages && excludedPages.length > 0) {
|
||||
const document = await this._instance.docViewer.getDocument().getPDFDoc();
|
||||
await clearStamps(document, this._instance.PDFNet, [...Array(this.fileData.fileStatus.numberOfPages).keys()]);
|
||||
const pdfNet = this._instance.Core.PDFNet;
|
||||
const document = await this._instance.Core.documentViewer.getDocument().getPDFDoc();
|
||||
await clearStamps(document, pdfNet, [...Array(this.fileData.fileStatus.numberOfPages).keys()]);
|
||||
await stampPDFPage(
|
||||
document,
|
||||
this._instance.PDFNet,
|
||||
pdfNet,
|
||||
this._translateService.instant('file-preview.excluded-from-redaction'),
|
||||
25,
|
||||
'courier',
|
||||
@ -568,8 +572,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
|
||||
private async _stampExcludedPages() {
|
||||
await this._doStampExcludedPages(this.fileData.fileStatus.excludedPages);
|
||||
this._instance.docViewer.refreshAll();
|
||||
this._instance.docViewer.updateView([this.activeViewerPage], this.activeViewerPage);
|
||||
this._instance.Core.documentViewer.refreshAll();
|
||||
this._instance.Core.documentViewer.updateView([this.activeViewerPage], this.activeViewerPage);
|
||||
this._changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
@ -678,9 +682,9 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
private _findAndDeleteAnnotation(id: string) {
|
||||
const viewerAnnotation = this._instance.annotManager.getAnnotationById(id);
|
||||
const viewerAnnotation = this._instance.Core.annotationManager.getAnnotationById(id);
|
||||
if (viewerAnnotation) {
|
||||
this._instance.annotManager.deleteAnnotation(viewerAnnotation, {
|
||||
this._instance.Core.annotationManager.deleteAnnotation(viewerAnnotation, {
|
||||
imported: true,
|
||||
force: true
|
||||
});
|
||||
@ -701,16 +705,16 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
private _getAnnotations(predicate: (value) => unknown) {
|
||||
const annotations = this._instance.annotManager.getAnnotationsList();
|
||||
const annotations = this._instance.Core.annotationManager.getAnnotationsList();
|
||||
return predicate ? annotations.filter(predicate) : annotations;
|
||||
}
|
||||
|
||||
private _hide(annotations: Annotations.Annotation[]): void {
|
||||
this._instance.annotManager.hideAnnotations(annotations);
|
||||
private _hide(annotations: Annotation[]): void {
|
||||
this._instance.Core.annotationManager.hideAnnotations(annotations);
|
||||
}
|
||||
|
||||
private _show(annotations: Annotations.Annotation[]): void {
|
||||
this._instance.annotManager.showAnnotations(annotations);
|
||||
private _show(annotations: Annotation[]): void {
|
||||
this._instance.Core.annotationManager.showAnnotations(annotations);
|
||||
}
|
||||
|
||||
private _setAnnotationsColor(annotations, customData: string) {
|
||||
|
||||
@ -10,7 +10,8 @@ import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { DossiersDialogService } from './dossiers-dialog.service';
|
||||
import { BASE_HREF } from '../../../tokens';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { Annotations } from '@pdftron/webviewer';
|
||||
import { Core } from '@pdftron/webviewer';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationActionsService {
|
||||
@ -281,7 +282,7 @@ export class AnnotationActionsService {
|
||||
return availableActions;
|
||||
}
|
||||
|
||||
updateHiddenAnnotation(annotations: AnnotationWrapper[], viewerAnnotations: Annotations.Annotation[], hidden: boolean) {
|
||||
updateHiddenAnnotation(annotations: AnnotationWrapper[], viewerAnnotations: Annotation[], hidden: boolean) {
|
||||
const annotationId = (viewerAnnotations[0] as any).Tw;
|
||||
const annotationToBeUpdated = annotations.find((a: AnnotationWrapper) => a.annotationId === annotationId);
|
||||
annotationToBeUpdated.hidden = hidden;
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import { Core, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import { Rectangle, RedactionLogControllerService, SectionGrid, SectionRectangle } from '@redaction/red-ui-http';
|
||||
import { hexToRgb } from '@utils/functions';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationDrawService {
|
||||
@ -14,18 +15,13 @@ export class AnnotationDrawService {
|
||||
private readonly _userPreferenceService: UserPreferenceService
|
||||
) {}
|
||||
|
||||
drawAnnotations(
|
||||
activeViewer: WebViewerInstance,
|
||||
annotationWrappers: AnnotationWrapper[],
|
||||
hideSkipped: boolean = false,
|
||||
compareMode: boolean = false
|
||||
) {
|
||||
drawAnnotations(activeViewer: WebViewerInstance, annotationWrappers: AnnotationWrapper[], hideSkipped = false, compareMode = false) {
|
||||
const annotations = [];
|
||||
annotationWrappers.forEach(annotation => {
|
||||
annotations.push(this.computeAnnotation(activeViewer, annotation, hideSkipped, compareMode));
|
||||
});
|
||||
|
||||
const annotationManager = activeViewer.annotManager;
|
||||
const annotationManager = activeViewer.Core.annotationManager;
|
||||
annotationManager.addAnnotations(annotations, { imported: true });
|
||||
annotationManager.drawAnnotationsFromList(annotations);
|
||||
|
||||
@ -49,14 +45,14 @@ export class AnnotationDrawService {
|
||||
// })
|
||||
});
|
||||
}
|
||||
const annotationManager = activeViewer.annotManager;
|
||||
const annotationManager = activeViewer.Core.annotationManager;
|
||||
annotationManager.addAnnotations(sections, { imported: true });
|
||||
annotationManager.drawAnnotationsFromList(sections);
|
||||
}
|
||||
|
||||
computeSection(activeViewer: WebViewerInstance, pageNumber: number, sectionRectangle: SectionRectangle) {
|
||||
const rectangleAnnot = new activeViewer.Annotations.RectangleAnnotation();
|
||||
const pageHeight = activeViewer.docViewer.getPageHeight(pageNumber);
|
||||
const rectangleAnnot = new activeViewer.Core.Annotations.RectangleAnnotation();
|
||||
const pageHeight = activeViewer.Core.documentViewer.getPageHeight(pageNumber);
|
||||
const rectangle = {
|
||||
topLeft: sectionRectangle.topLeft,
|
||||
page: pageNumber,
|
||||
@ -75,14 +71,9 @@ export class AnnotationDrawService {
|
||||
return rectangleAnnot;
|
||||
}
|
||||
|
||||
computeAnnotation(
|
||||
activeViewer: WebViewerInstance,
|
||||
annotationWrapper: AnnotationWrapper,
|
||||
hideSkipped: boolean = false,
|
||||
compareMode: boolean = false
|
||||
) {
|
||||
computeAnnotation(activeViewer: WebViewerInstance, annotationWrapper: AnnotationWrapper, hideSkipped = false, compareMode = false) {
|
||||
const pageNumber = compareMode ? annotationWrapper.pageNumber * 2 - 1 : annotationWrapper.pageNumber;
|
||||
const highlight = new activeViewer.Annotations.TextHighlightAnnotation();
|
||||
const highlight = new activeViewer.Core.Annotations.TextHighlightAnnotation();
|
||||
highlight.PageNumber = pageNumber;
|
||||
highlight.StrokeColor = this.getColor(activeViewer, annotationWrapper.superType, annotationWrapper.type);
|
||||
highlight.setContents(annotationWrapper.content);
|
||||
@ -96,13 +87,16 @@ export class AnnotationDrawService {
|
||||
(hideSkipped && annotationWrapper.isSkipped) ||
|
||||
annotationWrapper.isOCR ||
|
||||
annotationWrapper.hidden;
|
||||
highlight.setCustomData('redacto-manager', true);
|
||||
highlight.setCustomData('redaction', annotationWrapper.isRedacted);
|
||||
highlight.setCustomData('skipped', annotationWrapper.isSkipped);
|
||||
highlight.setCustomData('changeLog', annotationWrapper.isChangeLogEntry);
|
||||
highlight.setCustomData('changeLogRemoved', annotationWrapper.isChangeLogRemoved);
|
||||
highlight.setCustomData('redactionColor', this.getColor(activeViewer, 'redaction', 'redaction'));
|
||||
highlight.setCustomData('annotationColor', this.getColor(activeViewer, annotationWrapper.superType, annotationWrapper.type));
|
||||
highlight.setCustomData('redacto-manager', 'true');
|
||||
highlight.setCustomData('redaction', String(annotationWrapper.isRedacted));
|
||||
highlight.setCustomData('skipped', String(annotationWrapper.isSkipped));
|
||||
highlight.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry));
|
||||
highlight.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved));
|
||||
highlight.setCustomData('redactionColor', String(this.getColor(activeViewer, 'redaction', 'redaction')));
|
||||
highlight.setCustomData(
|
||||
'annotationColor',
|
||||
String(this.getColor(activeViewer, annotationWrapper.superType, annotationWrapper.type))
|
||||
);
|
||||
|
||||
return highlight;
|
||||
}
|
||||
@ -123,10 +117,10 @@ export class AnnotationDrawService {
|
||||
break;
|
||||
}
|
||||
const rgbColor = hexToRgb(color);
|
||||
return new activeViewer.Annotations.Color(rgbColor.r, rgbColor.g, rgbColor.b);
|
||||
return new activeViewer.Core.Annotations.Color(rgbColor.r, rgbColor.g, rgbColor.b);
|
||||
}
|
||||
|
||||
annotationToQuads(annotation: Annotations.Annotation, activeViewer: WebViewerInstance) {
|
||||
annotationToQuads(annotation: Annotation, activeViewer: WebViewerInstance) {
|
||||
const x1 = annotation.getRect().x1;
|
||||
const y1 = annotation.getRect().y1 + annotation.getRect().getHeight();
|
||||
|
||||
@ -139,11 +133,11 @@ export class AnnotationDrawService {
|
||||
const x4 = annotation.getRect().x1;
|
||||
const y4 = annotation.getRect().y1;
|
||||
|
||||
return new activeViewer.CoreControls.Math.Quad(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
return new activeViewer.Core.Math.Quad(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
private _rectanglesToQuads(positions: Rectangle[], activeViewer: WebViewerInstance, pageNumber: number): any[] {
|
||||
const pageHeight = activeViewer.docViewer.getPageHeight(pageNumber);
|
||||
const pageHeight = activeViewer.Core.documentViewer.getPageHeight(pageNumber);
|
||||
return positions.map(p => this._rectangleToQuad(p, activeViewer, pageHeight));
|
||||
}
|
||||
|
||||
@ -160,6 +154,6 @@ export class AnnotationDrawService {
|
||||
const x4 = rectangle.topLeft.x;
|
||||
const y4 = pageHeight - rectangle.topLeft.y;
|
||||
|
||||
return new activeViewer.CoreControls.Math.Quad(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
return new activeViewer.Core.Math.Quad(x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import { stampPDFPage } from '../../../utils/page-stamper';
|
||||
import { stampPDFPage } from '@utils/page-stamper';
|
||||
|
||||
const processPage = async (pageNumber, document1, document2, mergedDocument, PDFNet) => {
|
||||
const processPage = async (pageNumber, document1, document2, mergedDocument, pdfNet) => {
|
||||
const document1PageCount = await document1.getPageCount();
|
||||
if (document1PageCount >= pageNumber) {
|
||||
await mergedDocument.insertPages(pageNumber * 2, document1, pageNumber, pageNumber, PDFNet.PDFDoc.InsertFlag.e_none);
|
||||
await mergedDocument.insertPages(pageNumber * 2, document1, pageNumber, pageNumber, pdfNet.PDFDoc.InsertFlag.e_none);
|
||||
} else {
|
||||
const pageToCopy = await document2.getPage(pageNumber);
|
||||
const blankPage = await mergedDocument.pageCreate(await pageToCopy.getCropBox());
|
||||
await blankPage.setRotation(await pageToCopy.getRotation());
|
||||
await mergedDocument.pagePushBack(blankPage);
|
||||
await stampPDFPage(mergedDocument, PDFNet, '<< Compare Placeholder Page >>', 20, 'courier', 'DIAGONAL', 33, '#ffb83b', [
|
||||
await stampPDFPage(mergedDocument, pdfNet, '<< Compare Placeholder Page >>', 20, 'courier', 'DIAGONAL', 33, '#ffb83b', [
|
||||
await mergedDocument.getPageCount()
|
||||
]);
|
||||
}
|
||||
@ -25,17 +25,17 @@ export const loadCompareDocumentWrapper = async (
|
||||
fileStatus,
|
||||
setCompareViewMode: () => void,
|
||||
navigateToPage: () => void,
|
||||
PDFNet
|
||||
pdfNet: any
|
||||
) => {
|
||||
try {
|
||||
const maxPageCount = Math.max(currentDocumentPageCount, compareDocumentPageCount);
|
||||
|
||||
for (let idx = 1; idx <= maxPageCount; idx++) {
|
||||
await processPage(idx, currentDocument, compareDocument, mergedDocument, PDFNet);
|
||||
await processPage(idx, compareDocument, currentDocument, mergedDocument, PDFNet);
|
||||
await processPage(idx, currentDocument, compareDocument, mergedDocument, pdfNet);
|
||||
await processPage(idx, compareDocument, currentDocument, mergedDocument, pdfNet);
|
||||
}
|
||||
|
||||
const buffer = await mergedDocument.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
|
||||
const buffer = await mergedDocument.saveMemoryBuffer(pdfNet.SDFDoc.SaveOptions.e_linearized);
|
||||
|
||||
const mergedDocumentBuffer = new Blob([buffer], {
|
||||
type: 'application/pdf'
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
||||
// import { Annotations, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import { ViewMode } from '@models/file/view-mode';
|
||||
import { translateQuads } from '../../../utils/pdf-coordinates';
|
||||
import { translateQuads } from '@utils/pdf-coordinates';
|
||||
import { Rectangle } from '@redaction/red-ui-http';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { Core, WebViewerInstance } from '@pdftron/webviewer';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
const DISABLED_HOTKEYS = [
|
||||
'CTRL+SHIFT+EQUAL',
|
||||
@ -60,8 +62,8 @@ export class PdfViewerUtils {
|
||||
get currentPage() {
|
||||
try {
|
||||
return this.isCompareMode
|
||||
? Math.ceil(this.instance?.docViewer?.getCurrentPage() / 2)
|
||||
: this.instance?.docViewer?.getCurrentPage();
|
||||
? Math.ceil(this.instance?.Core.documentViewer?.getCurrentPage() / 2)
|
||||
: this.instance?.Core.documentViewer?.getCurrentPage();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@ -73,18 +75,20 @@ export class PdfViewerUtils {
|
||||
}
|
||||
|
||||
try {
|
||||
return this.isCompareMode ? Math.ceil(this.instance?.docViewer?.getPageCount() / 2) : this.instance?.docViewer?.getPageCount();
|
||||
return this.isCompareMode
|
||||
? Math.ceil(this.instance?.Core.documentViewer?.getPageCount() / 2)
|
||||
: this.instance?.Core.documentViewer?.getPageCount();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private get _currentInternalPage() {
|
||||
return this.instance?.docViewer?.getCurrentPage();
|
||||
return this.instance?.Core.documentViewer?.getCurrentPage();
|
||||
}
|
||||
|
||||
private get _totalInternalPages() {
|
||||
return this.instance?.docViewer?.getPageCount();
|
||||
return this.instance?.Core.documentViewer?.getPageCount();
|
||||
}
|
||||
|
||||
navigateToPage(pageNumber: string | number) {
|
||||
@ -106,17 +110,17 @@ export class PdfViewerUtils {
|
||||
|
||||
disableHotkeys(): void {
|
||||
for (const hotkey of DISABLED_HOTKEYS) {
|
||||
this.instance.hotkeys.off(hotkey);
|
||||
this.instance.UI.hotkeys.off(hotkey);
|
||||
}
|
||||
}
|
||||
|
||||
translateQuads(page: number, quads: any) {
|
||||
const rotation = this.instance.docViewer.getCompleteRotation(page);
|
||||
const rotation = this.instance.Core.documentViewer.getCompleteRotation(page);
|
||||
return translateQuads(page, rotation, quads);
|
||||
}
|
||||
|
||||
toPosition(page: number, selectedQuad: any): Rectangle {
|
||||
const pageHeight = this.instance.docViewer.getPageHeight(page);
|
||||
const pageHeight = this.instance.Core.documentViewer.getPageHeight(page);
|
||||
const height = selectedQuad.y2 - selectedQuad.y4;
|
||||
return {
|
||||
page: page,
|
||||
@ -130,7 +134,7 @@ export class PdfViewerUtils {
|
||||
}
|
||||
|
||||
deselectAllAnnotations() {
|
||||
this.instance.annotManager.deselectAllAnnotations();
|
||||
this.instance.Core.annotationManager.deselectAllAnnotations();
|
||||
}
|
||||
|
||||
selectAnnotations($event: AnnotationWrapper[] | { annotations: AnnotationWrapper[]; multiSelect: boolean }) {
|
||||
@ -149,24 +153,24 @@ export class PdfViewerUtils {
|
||||
}
|
||||
|
||||
const annotationsFromViewer = annotations.map(ann => this._getAnnotationById(ann.id));
|
||||
this.instance.annotManager.selectAnnotations(annotationsFromViewer);
|
||||
this.instance.Core.annotationManager.selectAnnotations(annotationsFromViewer);
|
||||
// this.navigateToPage(annotations[0].pageNumber*this.paginationOffset);
|
||||
this.instance.annotManager.jumpToAnnotation(annotationsFromViewer[0]);
|
||||
this.instance.Core.annotationManager.jumpToAnnotation(annotationsFromViewer[0]);
|
||||
}
|
||||
|
||||
deselectAnnotations(annotations: AnnotationWrapper[]) {
|
||||
const ann = annotations.map(a => this._getAnnotationById(a.id));
|
||||
this.instance.annotManager.deselectAnnotations(ann);
|
||||
this.instance.Core.annotationManager.deselectAnnotations(ann);
|
||||
}
|
||||
|
||||
private _navigateToPage(pageNumber) {
|
||||
const activePage = this.instance.docViewer.getCurrentPage();
|
||||
const activePage = this.instance.Core.documentViewer.getCurrentPage();
|
||||
if (activePage !== pageNumber) {
|
||||
this.instance.docViewer.displayPageLocation(pageNumber, 0, 0);
|
||||
this.instance.Core.documentViewer.displayPageLocation(pageNumber, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private _getAnnotationById(id: string): Annotations.Annotation {
|
||||
return this.instance.annotManager.getAnnotationById(id);
|
||||
private _getAnnotationById(id: string): Annotation {
|
||||
return this.instance.Core.annotationManager.getAnnotationById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { hexToRgb } from './functions';
|
||||
import { environment } from '@environments/environment';
|
||||
import { PDFNet } from '@pdftron/webviewer';
|
||||
import PDFDoc = PDFNet.PDFDoc;
|
||||
import { Core } from '@pdftron/webviewer';
|
||||
import PDFDoc = Core.PDFNet.PDFDoc;
|
||||
|
||||
export async function clearStamps(document: PDFDoc, PdfNet: any, pages: number[]) {
|
||||
await PdfNet.runWithCleanup(
|
||||
export async function clearStamps(document: PDFDoc, pdfNet: any, pages: number[]) {
|
||||
await pdfNet.runWithCleanup(
|
||||
async () => {
|
||||
await document.lock();
|
||||
const pageSet = await createPageSet(PdfNet, pages);
|
||||
await PdfNet.Stamper.deleteStamps(document, pageSet);
|
||||
const pageSet = await createPageSet(pdfNet, pages);
|
||||
await pdfNet.Stamper.deleteStamps(document, pageSet);
|
||||
},
|
||||
environment.licenseKey ? atob(environment.licenseKey) : null
|
||||
);
|
||||
@ -16,7 +16,7 @@ export async function clearStamps(document: PDFDoc, PdfNet: any, pages: number[]
|
||||
|
||||
export async function stampPDFPage(
|
||||
document: PDFDoc,
|
||||
PdfNet: any,
|
||||
pdfNet: any,
|
||||
text: string,
|
||||
fontSize: number,
|
||||
fontType: string,
|
||||
@ -25,17 +25,17 @@ export async function stampPDFPage(
|
||||
color: string,
|
||||
pages: number[]
|
||||
) {
|
||||
await PdfNet.runWithCleanup(
|
||||
await pdfNet.runWithCleanup(
|
||||
async () => {
|
||||
await document.lock();
|
||||
|
||||
const pageSet = await createPageSet(PdfNet, pages);
|
||||
await PdfNet.Stamper.deleteStamps(document, pageSet);
|
||||
const pageSet = await createPageSet(pdfNet, pages);
|
||||
await pdfNet.Stamper.deleteStamps(document, pageSet);
|
||||
|
||||
const rgbColor = hexToRgb(color);
|
||||
|
||||
const stamper = await PdfNet.Stamper.create(3, fontSize, 0);
|
||||
await stamper.setFontColor(await PdfNet.ColorPt.init(rgbColor.r / 255, rgbColor.g / 255, rgbColor.b / 255));
|
||||
const stamper = await pdfNet.Stamper.create(3, fontSize, 0);
|
||||
await stamper.setFontColor(await pdfNet.ColorPt.init(rgbColor.r / 255, rgbColor.g / 255, rgbColor.b / 255));
|
||||
await stamper.setOpacity(opacity / 100);
|
||||
|
||||
switch (orientation) {
|
||||
@ -51,7 +51,7 @@ export async function stampPDFPage(
|
||||
await stamper.setRotation(-45);
|
||||
}
|
||||
|
||||
const font = await PdfNet.Font.createAndEmbed(document, convertFont(fontType));
|
||||
const font = await pdfNet.Font.createAndEmbed(document, convertFont(fontType));
|
||||
await stamper.setFont(font);
|
||||
await stamper.setTextAlignment(0);
|
||||
await stamper.stampText(document, text, pageSet);
|
||||
@ -60,8 +60,8 @@ export async function stampPDFPage(
|
||||
);
|
||||
}
|
||||
|
||||
async function createPageSet(PdfNet: any, pages: number[]) {
|
||||
const pageSet = await PdfNet.PageSet.create();
|
||||
async function createPageSet(pdfNet: any, pages: number[]) {
|
||||
const pageSet = await pdfNet.PageSet.create();
|
||||
for (const page of pages) {
|
||||
if (page > 0) {
|
||||
await pageSet.addPage(page);
|
||||
|
||||
12
package.json
12
package.json
@ -55,12 +55,12 @@
|
||||
"@ngx-translate/core": "^13.0.0",
|
||||
"@ngx-translate/http-loader": "^6.0.0",
|
||||
"@nrwl/angular": "12.9.0",
|
||||
"@pdftron/webviewer": "7.3.3",
|
||||
"@pdftron/webviewer": "8.1.0",
|
||||
"@swimlane/ngx-charts": "^17.0.1",
|
||||
"file-saver": "^2.0.5",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"keycloak-angular": "^8.2.0",
|
||||
"keycloak-js": "13.0.1",
|
||||
"keycloak-angular": "^8.4.0",
|
||||
"keycloak-js": "15.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"messageformat": "^2.3.0",
|
||||
"moment": "^2.29.1",
|
||||
@ -98,10 +98,10 @@
|
||||
"@typescript-eslint/eslint-plugin": "4.31.0",
|
||||
"@typescript-eslint/parser": "4.31.0",
|
||||
"cypress": "^6.9.1",
|
||||
"cypress-file-upload": "^5.0.7",
|
||||
"cypress-file-upload": "^5.0.8",
|
||||
"cypress-keycloak": "^1.7.0",
|
||||
"cypress-keycloak-commands": "^1.2.0",
|
||||
"cypress-localstorage-commands": "^1.4.5",
|
||||
"cypress-localstorage-commands": "^1.5.0",
|
||||
"dotenv": "10.0.0",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-airbnb-typescript": "^14.0.0",
|
||||
@ -122,4 +122,4 @@
|
||||
"typescript": "4.3.5",
|
||||
"webpack": "^4.18.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
yarn.lock
40
yarn.lock
@ -3142,10 +3142,10 @@
|
||||
yargs "15.4.1"
|
||||
yargs-parser "20.0.0"
|
||||
|
||||
"@pdftron/webviewer@7.3.3":
|
||||
version "7.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@pdftron/webviewer/-/webviewer-7.3.3.tgz#e5ada58c4c4a4101a095507673ba2278042942ef"
|
||||
integrity sha512-cTJf9pXlN9tilliO8NgKw6vn1PPXSHKLOrUS7j4f+0sz2BJDVwO2rlI4BJBQ5BT2qIru1dg2GxYUyeXOqNyi9Q==
|
||||
"@pdftron/webviewer@8.1.0":
|
||||
version "8.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@pdftron/webviewer/-/webviewer-8.1.0.tgz#df0c48f1c81e76119e0dceb2233d1f26e6beaee0"
|
||||
integrity sha512-yLzxvNVUOK4xbQMfea7fiSENABFg/pQydqFCHOrXA+7ZB+hfMFNHz+zw/+yOcz3FiQEkvpwDy9fOTp2+kONu7w==
|
||||
|
||||
"@phenomnomnominal/tsquery@4.1.1", "@phenomnomnominal/tsquery@^4.1.1":
|
||||
version "4.1.1"
|
||||
@ -6034,10 +6034,10 @@ cyclist@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
|
||||
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
|
||||
|
||||
cypress-file-upload@^5.0.7:
|
||||
version "5.0.7"
|
||||
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.7.tgz#acf24fe08a92b2d0c892a58b56811fb933d34ea9"
|
||||
integrity sha512-cgWsWx7igxjyyVm9/VJ9ukdy69jL00I7z0lrwUWtXXLPvX4neO+8JAZ054Ax8Xf+mdV9OerenXzb9nqRoafjHA==
|
||||
cypress-file-upload@^5.0.8:
|
||||
version "5.0.8"
|
||||
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1"
|
||||
integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==
|
||||
|
||||
cypress-keycloak-commands@^1.2.0:
|
||||
version "1.2.0"
|
||||
@ -6049,10 +6049,10 @@ cypress-keycloak@^1.7.0:
|
||||
resolved "https://registry.yarnpkg.com/cypress-keycloak/-/cypress-keycloak-1.7.0.tgz#7556c297b12645405cd17d060d4fd6d1b73905ed"
|
||||
integrity sha512-sBlq7VUCTAUps/67mnDXg6rhVWS+PygspCGLfucmT/sQYanTVqmu374JCutNZGnNArOjmkaw0Rn80dC9dp9tJw==
|
||||
|
||||
cypress-localstorage-commands@^1.4.5:
|
||||
version "1.4.5"
|
||||
resolved "https://registry.yarnpkg.com/cypress-localstorage-commands/-/cypress-localstorage-commands-1.4.5.tgz#7e97f82c144314655ab7ecb4ce0e273c70d1e569"
|
||||
integrity sha512-mr86nv74GvOE4zOFwoMrksFCykNSbRh57Pg7xUGpm2ax+wfHhqwBA56Sn5dhHV73gzz7C6B1kfNpMrjMH/hgyg==
|
||||
cypress-localstorage-commands@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/cypress-localstorage-commands/-/cypress-localstorage-commands-1.5.0.tgz#53d67c1ce491dcbe39794151749b943227e65cd7"
|
||||
integrity sha512-gl1uKeviYdyJG4dLcZ9hfoUjLciwkkfbaQ3gvRtmipsPxC612ZBJhSjbunnJcUGwkryaM+82VrY9ij0tLSg7LA==
|
||||
|
||||
cypress@*:
|
||||
version "5.6.0"
|
||||
@ -9687,17 +9687,17 @@ karma-source-map-support@1.4.0:
|
||||
dependencies:
|
||||
source-map-support "^0.5.5"
|
||||
|
||||
keycloak-angular@^8.2.0:
|
||||
version "8.2.0"
|
||||
resolved "https://registry.yarnpkg.com/keycloak-angular/-/keycloak-angular-8.2.0.tgz#8c9f3902942fee3abfdae7aa88f155265e7fdba6"
|
||||
integrity sha512-ZOMCiFR+CavRJkjM2TuSK6nTJ1/mCuUXAQDrWKmKkbLNoM77ZSZNhVyk/GYhbyFNdquo+ASraiHyYXbYKFbSvQ==
|
||||
keycloak-angular@^8.4.0:
|
||||
version "8.4.0"
|
||||
resolved "https://registry.yarnpkg.com/keycloak-angular/-/keycloak-angular-8.4.0.tgz#405cb93cae8f01f3612d98caa5967e2c03372d04"
|
||||
integrity sha512-3zBKzPf+ZG+16EfOdp1uxa/XTGElTOQSq5UkfFJzFcJe1D6p696hKIUJHNJECcYNUtt4XhYwUEolMIR+VySqgA==
|
||||
dependencies:
|
||||
tslib "^2.0.0"
|
||||
|
||||
keycloak-js@13.0.1:
|
||||
version "13.0.1"
|
||||
resolved "https://registry.yarnpkg.com/keycloak-js/-/keycloak-js-13.0.1.tgz#4aae6a8fe1301aa3d7a12b2de6227a23b42f275d"
|
||||
integrity sha512-S9mFX8HHlgw+i2HAIhteccrkffQmUn4CpYcU8ViGnODSBcnaf2YTtLhiiRH/a6SaOBpxmJTN3XVIZbE9d/HyXQ==
|
||||
keycloak-js@15.0.2:
|
||||
version "15.0.2"
|
||||
resolved "https://registry.yarnpkg.com/keycloak-js/-/keycloak-js-15.0.2.tgz#9d12dd8860953a267b9b18f351ad2e76b8e94a9c"
|
||||
integrity sha512-dv2a4NcPSH3AzGWG3ZtB+VrHpuQLdFBYXtQBj/+oBzm6XNwnVAMdL6LIC0OzCLQpn3rKTQJtNSATAGhbKJgewQ==
|
||||
dependencies:
|
||||
base64-js "1.3.1"
|
||||
js-sha256 "0.9.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user