Skip to content
Snippets Groups Projects
Unverified Commit 86528516 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Adapt positioning and angle in rotated states to fit PDF-AS (#8)

parent 1c049db0
No related branches found
No related tags found
No related merge requests found
Pipeline #11587 passed
...@@ -153,15 +153,39 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle ...@@ -153,15 +153,39 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle
if (this.queuedFilesPlacementModes[key] === "manual") { if (this.queuedFilesPlacementModes[key] === "manual") {
const data = this.queuedFilesSignaturePlacements[key]; const data = this.queuedFilesSignaturePlacements[key];
// rotation translation if (data !== undefined) {
let angle = data.angle;
let bottom = data.bottom;
let left = data.left;
if (angle !== 0) {
// attempt to adapt positioning in the rotated states to fit PDF-AS
switch (angle) {
case 90:
// 321 / 118;
bottom += data.width / 2.72034;
left -= data.width / 2.72034;
break;
case 180:
// 321 / 237;
bottom += data.width / 1.3544;
break;
case 270:
left += data.height;
bottom += data.height;
break;
}
// adapt rotation to fit PDF-AS
const rotations = {0: 0, 90: 270, 180: 180, 270: 90}; const rotations = {0: 0, 90: 270, 180: 180, 270: 90};
angle = rotations[data.angle];
}
if (data !== undefined) {
params = { params = {
y: data.bottom, y: Math.round(bottom),
x: data.left, x: Math.round(left),
r: rotations[data.angle], r: angle,
w: data.width, // only width, no "height" allowed in PDF-AS w: Math.round(data.width), // only width, no "height" allowed in PDF-AS
p: data.currentPage p: data.currentPage
}; };
} }
...@@ -273,7 +297,6 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle ...@@ -273,7 +297,6 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle
const apiUrl = jsonld.getApiUrlForEntityName("QualifiedlySignedDocument") + '/' + sessionId + '?fileName=' + const apiUrl = jsonld.getApiUrlForEntityName("QualifiedlySignedDocument") + '/' + sessionId + '?fileName=' +
encodeURI(fileName); encodeURI(fileName);
// TODO: Improve error handling
fetch(apiUrl, { fetch(apiUrl, {
headers: { headers: {
'Content-Type': 'application/ld+json', 'Content-Type': 'application/ld+json',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment