Skip to content
Snippets Groups Projects
Commit 289dc67e authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #18091 TIME 2:30 calculate the original size of the signature

parent b0883e37
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,8 @@ export class SignaturesComponent implements OnInit { ...@@ -37,6 +37,8 @@ export class SignaturesComponent implements OnInit {
inAllPage = false; inAllPage = false;
count = 0; count = 0;
realSizes: any[] = [];
constructor(private translate: TranslateService, constructor(private translate: TranslateService,
public http: HttpClient, public http: HttpClient,
public signaturesService: SignaturesContentService, public signaturesService: SignaturesContentService,
...@@ -91,6 +93,7 @@ export class SignaturesComponent implements OnInit { ...@@ -91,6 +93,7 @@ export class SignaturesComponent implements OnInit {
if (obj.length > 0) { if (obj.length > 0) {
this.signaturesList.push(obj); this.signaturesList.push(obj);
} }
this.getImgDimensions(this.signaturesList);
} }
ionViewDidEnter() { ionViewDidEnter() {
...@@ -115,11 +118,13 @@ export class SignaturesComponent implements OnInit { ...@@ -115,11 +118,13 @@ export class SignaturesComponent implements OnInit {
selectSignature(signature: any) { selectSignature(signature: any) {
let percentWidth: any; let percentWidth: any;
const realWith: number = this.realSizes.find((sign: any) => sign.id === signature.id).width;
const signatureScaling: any = this.authService.user.preferences.signatureScaling; const signatureScaling: any = this.authService.user.preferences.signatureScaling;
const signatureWith: number = realWith > this.signaturesService.workingAreaWidth ? 100 : (realWith * 100) / this.signaturesService.workingAreaWidth;
if (signatureScaling === undefined) { if (signatureScaling === undefined) {
percentWidth = 25; percentWidth = 25;
} else { } else {
percentWidth = signatureScaling === false ? (400 * 100) / this.signaturesService.workingAreaWidth : signatureScaling; percentWidth = signatureScaling === false ? signatureWith : signatureScaling;
} }
signature.width = percentWidth; signature.width = percentWidth;
const signPosCurrentPage = this.currentWorflow.signaturePositions.filter((item: any) => item.page === this.signaturesService.currentPage); const signPosCurrentPage = this.currentWorflow.signaturePositions.filter((item: any) => item.page === this.signaturesService.currentPage);
...@@ -329,4 +334,22 @@ export class SignaturesComponent implements OnInit { ...@@ -329,4 +334,22 @@ export class SignaturesComponent implements OnInit {
} }
return state; return state;
} }
getImgDimensions(signList: any[]) {
this.realSizes = [];
signList.forEach((sign: any[]) => {
sign.forEach((img: any) => {
const decodeBase64 = atob(img.encodedSignature.slice(0, 50)).slice(16, 24);
const uint8 = Uint8Array.from(decodeBase64, c => c.charCodeAt(0));
const dataView = new DataView(uint8.buffer);
this.realSizes.push(
{
id: img.id,
width: dataView.getInt32(0),
height: dataView.getInt32(4)
}
);
});
});
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment