diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts
index 86d12654532e2e118e9406433657c394f1c02d05..f5732e14764dd8cc642586a3f48ade5b39c41442 100755
--- a/src/frontend/app/document/document.component.ts
+++ b/src/frontend/app/document/document.component.ts
@@ -42,16 +42,6 @@ export class DocumentComponent implements OnInit {
     @ViewChild('rightContent', { static: true }) rightContent: TemplateRef<any>;
     @ViewChild('pagesList') pagesList: any;
 
-    posX: number = 0;
-    posY: number = 0;
-    enterApp: boolean = true;
-    detailMode: boolean = false;
-    pageNum: number = 1;
-    signaturesContent: any = [];
-    totalPages: number;
-    draggable: boolean;
-    currentDoc: number = 0;
-    docList: any = [];
     actionsList: any = [
         {
             id: 2,
@@ -75,12 +65,6 @@ export class DocumentComponent implements OnInit {
             event: 'validateDocument'
         },
     ];
-    pdfDataArr: any;
-    freezeSidenavClose: boolean = false;
-    startX: number = 0;
-    startY: number = 0;
-    widthDoc: string = '100%';
-    resetDragPos: boolean = false;
 
     mainDocument: any = {
         id: 0,
@@ -89,45 +73,56 @@ export class DocumentComponent implements OnInit {
         workflow: [],
     };
 
-    loadingUI: any = false;
+    signaturesContent: any = [];
+    docList: any = [];
+
+    posX: number = 0;
+    posY: number = 0;
+    pageNum: number = 1;
+    currentDoc: number = 0;
+    totalPages: number;
 
+    detailMode: boolean = false;
+    draggable: boolean;
     expandedNote: boolean = true;
-    hasWorkflowNotes: boolean = false;
-    currentTool = 'info';
-    load: HTMLIonLoadingElement = null;
     dragging: boolean = false;
     resizing: boolean = false;
-    pdfname: string = null;
     loadingdocument: boolean = true;
     loadingpdf: boolean = false;
     loadingImage: boolean = true;
+    hasWorkflowNotes: boolean = false;
 
+    currentTool: string = 'info';
+    pdfname: string = null;
     fileContent: string = '';
     userMode: string = '';
 
-    constructor(private translate: TranslateService,
-        private router: Router,
-        private route: ActivatedRoute,
+    load: HTMLIonLoadingElement = null;
+
+    constructor(
         public http: HttpClient,
         public signaturesService: SignaturesContentService,
         public notificationService: NotificationService,
-        private cookieService: CookieService,
         public sanitizer: DomSanitizer,
         public dialog: MatDialog,
-        private bottomSheet: MatBottomSheet,
         public authService: AuthService,
-        private localStorage: LocalStorageService,
-        private menu: MenuController,
         public actionSheetController: ActionSheetController,
         public loadingController: LoadingController,
         public viewContainerRef: ViewContainerRef,
         public modalController: ModalController,
-        private pdfViewerService: NgxExtendedPdfViewerService,
         public alertController: AlertController,
         public signatureMethodService: SignatureMethodService,
         public navCtrl: NavController,
         public functionsService: FunctionsService,
         public actionsService: ActionsService,
+        private translate: TranslateService,
+        private router: Router,
+        private route: ActivatedRoute,
+        private bottomSheet: MatBottomSheet,
+        private localStorage: LocalStorageService,
+        private menu: MenuController,
+        private pdfViewerService: NgxExtendedPdfViewerService,
+        private cookieService: CookieService,
     ) {
         this.draggable = false;
     }
@@ -147,7 +142,6 @@ export class DocumentComponent implements OnInit {
     getImageDimensions(ajustSize: boolean = false): void {
         const img = new Image();
         img.onload = (data: any) => {
-
             const percent = (data.target.naturalWidth * 100) / this.signaturesService.workingAreaWidth;
 
             this.signaturesService.workingAreaWidth = data.target.naturalWidth;
@@ -156,33 +150,14 @@ export class DocumentComponent implements OnInit {
             if (ajustSize) {
                 this.getAreaDimension();
             }
-
-            /* if (percent !== Infinity) {
-                this.signatures.forEach(element => {
-                    element.position.height = (percent * element.position.height) / 100;
-                    element.position.width = (percent * element.position.width) / 100;
-                    element.position.top = (percent * element.position.top) / 100;
-                    element.position.left = (percent * element.position.left) / 100;
-                });
-            }*/
-            // this.originalSize = true;
         };
         img.src = this.docList[this.currentDoc].imgContent[this.pageNum];
     }
 
     getAreaDimension() {
         const percent = (this.mainContent.el.offsetWidth * 100) / this.signaturesService.workingAreaWidth;
-
         this.signaturesService.workingAreaWidth = (percent * this.signaturesService.workingAreaWidth) / 100;
         this.signaturesService.workingAreaHeight = (percent * this.signaturesService.workingAreaHeight) / 100;
-
-        /* this.signatures.forEach(element => {
-          element.position.height = (percent * element.position.height) / 100;
-          element.position.width = (percent * element.position.width) / 100;
-          element.position.top = (percent * element.position.top) / 100;
-          element.position.left = (percent * element.position.left) / 100;
-        });*/
-        // this.originalSize = false;
     }
 
     async openAction(event: any) {
@@ -217,25 +192,7 @@ export class DocumentComponent implements OnInit {
                 }
             });
         }
-        /* if (this.originalSize) {
-          buttons.push({
-            text: 'Zoom taille écran',
-            icon: 'contract-outline',
-            handler: () => {
-              this.getAreaDimension();
-              console.log('Share clicked');
-            }
-          });
-        } else {
-          buttons.push({
-            text: 'Zoom taille écran',
-            icon: 'contract-outline',
-            handler: () => {
-              this.getImageDimensions();
-              console.log('Share clicked');
-            }
-          });
-        } */
+
         if (!this.checkEmptiness(true, true, true)) {
             buttons.push({
                 text: this.translate.instant('lang.deleteAll'),
@@ -335,109 +292,117 @@ export class DocumentComponent implements OnInit {
                 }).then((load: HTMLIonLoadingElement) => {
                     this.load = load;
                     this.load.present();
-                    this.http.get('../rest/documents/' + params['id']).pipe(
-                        tap((data: any) => {
-                            this.mainDocument = data.document;
-                            this.mainDocument.workflow = this.mainDocument.workflow.map((item: any) => {
-                                if (item.note) {
-                                    this.hasWorkflowNotes = true;
-                                }
-                                item.signatureMode = item.userId === null && item.mode === 'sign' && item.signatureMode === 'stamp' ? 'sign' : item.signatureMode;
-                                let modes = ['visa', 'sign'].concat(item.userSignatureModes);
-                                if (item.signatureMode === 'otp_sign_yousign') {
-                                    modes = modes.concat(['otp_sign_yousign']);
-                                }
-                                if (item.signatureMode === 'otp_visa_yousign') {
-                                    modes = modes.concat(['otp_visa_yousign']);
-                                }
-                                return {
-                                    ...item,
-                                    'role': item.mode === 'visa' ? 'visa' : item.signatureMode,
-                                    'modes': modes
-                                };
-                            });
+                    this.initDocumentInfos(params);
+                });
+            }
+        });
+    }
 
-                            this.totalPages = this.mainDocument.pages;
-
-                            this.signaturesService.mainDocumentId = this.mainDocument.id;
-                            this.signaturesService.totalPage = this.mainDocument.pages;
-                            this.menu.enable(true, 'right-menu');
-                            this.initDoc();
-
-                            const realUserWorkflow = this.mainDocument.workflow.filter((line: { current: boolean }) => line.current === true);
-
-                            this.mainDocument.isCertified = this.mainDocument.workflow.filter((line: any) => line.status !== 'REF' && line.status !== 'STOP' && line.mode.indexOf('sign') > -1 && line.signatureMode !== 'stamp' && line.processDate !== null).length > 0;
-                            const externalUser: any = this.mainDocument.workflow.filter((user: any) => user.userId === null && user.current === true);
-                            if (realUserWorkflow.length === 0 || this.mainDocument.readOnly || externalUser.length > 0) {
-                                this.actionsList = [
-                                    {
-                                        id: 4,
-                                        label: 'lang.back',
-                                        color: 'medium',
-                                        logo: 'chevron-back-outline',
-                                        event: 'back'
-                                    },
-                                ];
-                                this.detailMode = true;
-                            } else {
-                                this.signaturesService.stampLock = this.mainDocument.isCertified && ((realUserWorkflow[0].signatureMode === 'stamp' && realUserWorkflow[0].mode === 'sign') || (realUserWorkflow[0].mode === 'visa'));
-                                if (realUserWorkflow[0].userId !== this.authService.user.id) {
-                                    this.http.get('../rest/users/' + realUserWorkflow[0].userId + '/signatures')
-                                        .subscribe((dataSign: any) => {
-                                            this.signaturesService.signaturesListSubstituted = dataSign.signatures;
-                                        });
-                                } else {
-                                    this.signaturesService.signaturesListSubstituted = [];
-                                }
-                                if (realUserWorkflow[0].datePositions.length > 0 && this.functionsService.empty(this.signaturesService.datesContent)) {
-                                    realUserWorkflow[0].datePositions.forEach((date: any) => {
-                                        if (!this.signaturesService.datesContent[date.page]) {
-                                            this.signaturesService.datesContent[date.page] = [];
-                                        }
-                                        this.signaturesService.datesContent[date.page][0] = {
-                                            width: date.width,
-                                            height: date.height,
-                                            positionX: date.positionX,
-                                            positionY: date.positionY,
-                                            font: date.font,
-                                            size: date.size,
-                                            color: date.color,
-                                            format: date.format
-                                        };
-                                    });
-                                }
-                            }
+    initDocumentInfos(params: any) {
+        this.http.get('../rest/documents/' + params['id']).pipe(
+            tap((data: any) => {
+                this.mainDocument = data.document;
+                this.mainDocument.workflow = this.mainDocument.workflow.map((item: any) => {
+                    if (item.note) {
+                        this.hasWorkflowNotes = true;
+                    }
+                    item.signatureMode = item.userId === null && item.mode === 'sign' && item.signatureMode === 'stamp' ? 'sign' : item.signatureMode;
+                    let modes = ['visa', 'sign'].concat(item.userSignatureModes);
+                    if (item.signatureMode === 'otp_sign_yousign') {
+                        modes = modes.concat(['otp_sign_yousign']);
+                    }
+                    if (item.signatureMode === 'otp_visa_yousign') {
+                        modes = modes.concat(['otp_visa_yousign']);
+                    }
+                    return {
+                        ...item,
+                        role: item.mode === 'visa' ? 'visa' : item.signatureMode,
+                        modes: modes
+                    };
+                });
 
-                            this.docList.push({ 'id': this.mainDocument.id, 'title': this.mainDocument.title, 'pages': this.mainDocument.pages, 'imgContent': [], 'imgUrl': '../rest/documents/' + this.mainDocument.id + '/thumbnails' });
-                            this.mainDocument.attachments.forEach((attach: any) => {
-                                this.docList.push({ 'id': attach.id, 'title': attach.title, 'pages': attach.pages, 'imgContent': [], 'imgUrl': '../rest/attachments/' + attach.id + '/thumbnails' });
+                this.totalPages = this.mainDocument.pages;
+                this.signaturesService.mainDocumentId = this.mainDocument.id;
+                this.signaturesService.totalPage = this.mainDocument.pages;
+                this.menu.enable(true, 'right-menu');
+                this.initDoc();
+
+                const realUserWorkflow = this.mainDocument.workflow.filter((line: { current: boolean }) => line.current === true);
+
+                this.mainDocument.isCertified = this.mainDocument.workflow.filter((line: any) => line.status !== 'REF' && line.status !== 'STOP' && line.mode.indexOf('sign') > -1 && line.signatureMode !== 'stamp' && line.processDate !== null).length > 0;
+                const externalUser: any = this.mainDocument.workflow.filter((user: any) => user.userId === null && user.current === true);
+                if (realUserWorkflow.length === 0 || this.mainDocument.readOnly || externalUser.length > 0) {
+                    this.actionsList = [
+                        {
+                            id: 4,
+                            label: 'lang.back',
+                            color: 'medium',
+                            logo: 'chevron-back-outline',
+                            event: 'back'
+                        },
+                    ];
+                    this.detailMode = true;
+                } else {
+                    this.signaturesService.stampLock = this.mainDocument.isCertified && ((realUserWorkflow[0].signatureMode === 'stamp' && realUserWorkflow[0].mode === 'sign') || (realUserWorkflow[0].mode === 'visa'));
+                    if (realUserWorkflow[0].userId !== this.authService.user.id) {
+                        this.http.get('../rest/users/' + realUserWorkflow[0].userId + '/signatures')
+                            .subscribe((dataSign: any) => {
+                                this.signaturesService.signaturesListSubstituted = dataSign.signatures;
                             });
-                            this.menu.enable(true, 'right-menu');
-                            // this.renderPdf();
-                            this.renderImage();
-                            this.loadingdocument = false;
-                        }),
-                        catchError((err: any) => {
-                            console.log('error', err);
-                            setTimeout(() => {
-                                this.load.dismiss();
-                            }, 200);
-                            this.notificationService.handleErrors(err);
-                            this.router.navigate(['/home']);
-                            return of(false);
-                        })
-                    ).subscribe();
+                    } else {
+                        this.signaturesService.signaturesListSubstituted = [];
+                    }
+                    if (realUserWorkflow[0].datePositions.length > 0 && this.functionsService.empty(this.signaturesService.datesContent)) {
+                        realUserWorkflow[0].datePositions.forEach((date: any) => {
+                            if (!this.signaturesService.datesContent[date.page]) {
+                                this.signaturesService.datesContent[date.page] = [];
+                            }
+                            this.signaturesService.datesContent[date.page][0] = {
+                                width: date.width,
+                                height: date.height,
+                                positionX: date.positionX,
+                                positionY: date.positionY,
+                                font: date.font,
+                                size: date.size,
+                                color: date.color,
+                                format: date.format
+                            };
+                        });
+                    }
+                }
+
+                this.docList.push({ 'id': this.mainDocument.id, 'title': this.mainDocument.title, 'pages': this.mainDocument.pages, 'imgContent': [], 'imgUrl': '../rest/documents/' + this.mainDocument.id + '/thumbnails' });
+                this.mainDocument.attachments.forEach((attach: any) => {
+                    this.docList.push({ 'id': attach.id, 'title': attach.title, 'pages': attach.pages, 'imgContent': [], 'imgUrl': '../rest/attachments/' + attach.id + '/thumbnails' });
                 });
-            }
-        });
+                this.menu.enable(true, 'right-menu');
+                // this.renderPdf();
+                this.renderImage();
+                this.loadingdocument = false;
+            }),
+            catchError((err: any) => {
+                console.log('error', err);
+                setTimeout(() => {
+                    this.load.dismiss();
+                }, 200);
+                this.notificationService.handleErrors(err);
+                this.router.navigate(['/home']);
+                return of(false);
+            })
+        ).subscribe();
     }
 
     renderPdf() {
-        this.http.get('../rest/documents/' + this.docList[this.currentDoc].id + '/content')
-            .subscribe((data: any) => {
+        this.http.get('../rest/documents/' + this.docList[this.currentDoc].id + '/content').pipe(
+            tap((data: any) => {
                 this.pdfname = 'data:application/pdf;base64,' + data.encodedDocument;
                 this.loadingpdf = true;
-            });
+            }),
+            catchError((err: any) => {
+                this.notificationService.handleErrors(err);
+                return of(false);
+            })
+        ).subscribe();
     }
 
     async onPagesLoaded(ev: any) {
@@ -509,55 +474,12 @@ export class DocumentComponent implements OnInit {
         this.currentDoc = 0;
     }
 
-    testDrag(event: any) {
-        const element = event.source.getRootElement();
-        const boundingClientRect = element.getBoundingClientRect();
-        const parentPosition = this.getPosition(element);
-
-        this.signaturesService.y = (boundingClientRect.y - parentPosition.top);
-        this.signaturesService.x = (boundingClientRect.x - parentPosition.left);
-    }
-
-    getPosition(el: any) {
-        let x = 0;
-        let y = 0;
-        while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
-            x += el.offsetLeft - el.scrollLeft;
-            y += el.offsetTop - el.scrollTop;
-            el = el.offsetParent;
-        }
-        return { top: y, left: x };
-    }
-
-    zoomForNotes() {
-        this.widthDoc = '200%';
-        this.signaturesService.scale = 2;
-        $('.example-box').css({ 'transform': 'translate3d(' + this.signaturesService.x * this.signaturesService.scale + 'px, ' + this.signaturesService.y * this.signaturesService.scale + 'px, 0px)' });
-
-        this.signaturesService.workingAreaHeight *= this.signaturesService.scale;
-        this.signaturesService.workingAreaWidth *= this.signaturesService.scale;
-
-    }
-
-    zoomForView() {
-        this.resetDragPos = true;
-        this.widthDoc = '100%';
-        this.signaturesService.workingAreaHeight = this.signaturesService.workingAreaHeight / 2;
-        this.signaturesService.workingAreaWidth = this.signaturesService.workingAreaWidth / 2;
-        setTimeout(() => {
-            this.resetDragPos = false;
-        }, 200);
-        this.signaturesService.scale = 1;
-
-    }
-
     prevPage() {
         this.loadingImage = true;
         this.pageNum--;
 
         if (this.pageNum === 0) {
             this.pageNum = 1;
-        } else {
         }
 
         if (this.currentDoc === 0) {
@@ -606,15 +528,6 @@ export class DocumentComponent implements OnInit {
         return Array(n);
     }
 
-    initWorkingArea() {
-        /* if ((typeof this.signaturesService.workingAreaHeight !== 'number' || this.signaturesService.workingAreaHeight === 0) && (typeof this.signaturesService.workingAreaWidth !== 'number' || this.signaturesService.workingAreaWidth === 0)) {
-            this.img = document.querySelector('img.zoom');
-            const rect = this.img.getBoundingClientRect();
-            this.signaturesService.workingAreaHeight = rect.height;
-            this.signaturesService.workingAreaWidth = rect.width;
-        }*/
-    }
-
     async refuseDocument(): Promise<void> {
         let msg: string = this.translate.instant('lang.rejectDocumentWarning');
         const mode: string = this.mainDocument.workflow.find((item: any) => item.current).mode;
@@ -641,7 +554,6 @@ export class DocumentComponent implements OnInit {
                     handler: async (data: any) => {
                         this.signaturesService.signaturesContent = [];
                         const idsToProcess = await this.actionsService.checkGroupMail(this.mainDocument, 'reject');
-
                         const res = await this.signatureMethodService.launchDefaultMode(data.paragraph, idsToProcess);
 
                         if (!this.functionsService.empty(res)) {
@@ -686,7 +598,6 @@ export class DocumentComponent implements OnInit {
                     handler: async (data: any) => {
                         const currentUserWorkflow = this.mainDocument.workflow.filter((line: { current: boolean }) => line.current === true)[0];
                         const idsToProcess = await this.actionsService.checkGroupMail(this.mainDocument, 'validate');
-
                         const res = await this.signatureMethodService.checkAuthenticationAndLaunchAction(currentUserWorkflow, data.paragraph, idsToProcess);
 
                         if (!this.functionsService.empty(res)) {
@@ -811,18 +722,6 @@ export class DocumentComponent implements OnInit {
         this.signaturesService.currentToobal = 'mainDocumentDetail';
     }
 
-    deleteSubstution() {
-        const r = confirm(this.translate.instant('lang.deleteSubstitution') + ' ?');
-
-        if (r) {
-            this.http.put('../rest/users/' + this.authService.user.id + '/substitute', { substitute: null })
-                .subscribe(() => {
-                    this.authService.updateUserInfoWithTokenRefresh();
-                    this.notificationService.success('lang.substitutionDeleted');
-                });
-        }
-    }
-
     back() {
         this.navCtrl.back();
     }
@@ -839,15 +738,6 @@ export class DocumentComponent implements OnInit {
         }
     }
 
-    fromHex(hexString: any) {
-        const res = new Uint8Array(hexString.length / 2);
-        for (let i = 0; i < hexString.length; i = i + 2) {
-            const c = hexString.slice(i, i + 2);
-            res[i / 2] = parseInt(c, 16);
-        }
-        return res.buffer;
-    }
-
     canShowActions() {
         return this.currentDoc === 0 && !this.detailMode && !this.signaturesService.stampLock;
     }