How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 11, 2023 at 09:50amHi Team,
I am trying to figure out the way to convert the unit measurement in our system (millimeter) to OneSpan unit.
Today we use this formula to convert the signature coordinates in my application to OneSpan:
my application value ( in millimeter) x 3.6869 = OneSpan value
for example:
- signature field in my application
- top: 259.09592476489024
- left: 27.07210031347962
- width: 60.912225705329135
- height: 20.30407523510971
will be converted to below and submit to OneSpan
[
{
"id": "document_id",
"role": "signer_role",
"optional": false,
"fields": [
{
"id": "d1e100000",
"page": 0,
"type": "SIGNATURE",
"subtype": "CAPTURE",
"binding": null,
"value": null,
"top": 955.2607650156739,
"left": 99.81212664576802,
"height": 74.85909498432599,
"width": 224.577284952978,
"validation": null,
"fontSize": 8
}
]
}
]
The problem that we are dealing with this formula right now is sometimes when the signature placed too close to the edges it will convert to the coordinates that outside the boundary and throw below error:
{
"messageKey": "error.validation.invalidPageLocation",
"parameters": {
"approvalDataName": "",
"documentName": ""
},
"message": "Invalid position. Object placed outside of document page boundary.",
"code": 400,
"name": "Validation Error"
}
So it will be helpful if someone can help us understand the measurement unit that OneSpan using so we can come up with better conversion.
Thanks,
Vang Nguyen
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 11, 2023 at 10:18amHi Vang Nguyen,
Thanks for your post!
OneSpan Sign doc engine uses 93.6dpi (inch to px) to convert document pages, that makes:
1mm = 1/25.4 * 93.6 px
This is slightly smaller than 3.6869 that's maybe why the right bottom edge exceeds the page boundary. If you floor this number (1/25.4 * 93.6), it should help avoid the issue.
Let me know how this works for you.
Duo
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 11, 2023 at 10:20amThank you so much for your quick response, we will try it and keep you posted.
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 09:20amHi Duo Lang,
We have applied the fix to use (1/25.4 * 93.6) = 3.685 (round to 4 decimal) but the issue is still happening, I think it is because of the page is long and we place the signature close to bottom edges, it would introduce more gap on this conversion. floor this (1/25.4 * 93.6) would resolve the issue but we will have big gap on my signature placement tool vs. actual signature appear on OneSpan signing document. I wonder if OneSpan has any API that can tell us the height of the document beforehand? that way we can validate my signature coordinates and adjust it before submit to OneSpan.
Thanks,
Vang Nguyen
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 10:09amHi Vang Nguyen,
Thanks for your reply! For a 8.5in * 11in A4 page, OSS converts it to 796px * 1030px, using 93.6dpi.
Below is an example from my test:
I've added a text form at bottom right, and the Adobe Acrobat shows the position is (see the attachment):
Top = 257.5687 mm
Left = 174.5691 mm
Height = 41.2166 mm
Width = 21.6027 mm
After conversion they became:
Top = 949.1406 px
Left = 643.2863 px
Height = 79.6070 px
Width = 151.8872 px
In OSS system, the locations are stored as:
height: 80 px
left: 643 px
top: 949 px
width: 152 px
page size is:
width: 796 px
height: 1030 px
There's one pixel gap in bottom and right which is kind of inevitable since numbers are stored as integer in OSS.
If you are experiencing a big gap on signature placement tool vs. actual signature appear on OneSpan signing document, could you give me an example and I will look closer into that.
Best Regards,
Duo
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 11:08amPlease help to run below test
my system signature coordinates:
height: 14.877061040024874
width: 44.631183120074624
left: 165.44798354659204
top: 282.16182784886405
document size:
height: 297.0388888888889
width: 210.07916666666668
document size in OneSpan
{
"id": "",
"left": 0.0,
"width": 774.0,
"height": 1093.0,
"top": 0.0,
"version": 0,
"index": 2
}
with the pixelDensity=3.685
my conversion would be
top: 282.16182784886405 x 3.685 = 1039.766335623064
height of signature: 14.877061040024874 x 3.685 = 54.82196993249166
top + height = 1094.58830555555566 so it is like 1.58px off the page.
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 11:36amHi Vang Nguyen,
I think your page is slightly longer than 279.4mm (11inch), hence can you share a blank PDF with this page size for me to test?
Duo
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 11:48amPlease use the attached PDF for testing we got the issue on 3rd page
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 12:02pmHi Vang Nguyen,
Thanks for the information! I think the issue is caused because the coordinates are only stored as integer in OSS system. Does floor to get lowest integer work for you since it's at most 1px offset? So you have:
top: 282.16182784886405 x 3.685 = 1039.766335623064 = 1039
height of signature: 14.877061040024874 x 3.685 = 54.82196993249166 = 54
Duo
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Thursday, May 25, 2023 at 12:40pmThank you so much, We will try to floor that number before sending it to OSS and I will keep you posted.
Reply to: How to convert signature coordinates from millimeter unit to OneSpan unit?
Friday, May 26, 2023 at 08:37amBTW,
We are trying to mimic the OneSpan page size calculation but the result is just one pixel different. I am trying figure out the rounding in OneSpan
This the formula that we use
pixel = Math.round((points * 93.6) / 72);
My result:
Page Sizes:
Page 0 - Width: 796, Height: 1030
Page 1 - Width: 796, Height: 1030
Page 2 - Width: 774, Height: 1094 // This third page is one pixel different to OneSpan result
One Span result
"pages": [
{
"id": "",
"left": 0.0,
"width": 796.0,
"height": 1030.0,
"top": 0.0,
"index": 0,
"version": 0
},
{
"id": "",
"left": 0.0,
"width": 796.0,
"height": 1030.0,
"top": 0.0,
"index": 1,
"version": 0
},
{
"id": "",
"left": 0.0,
"width": 774.0,
"height": 1093.0, // The different is on this page
"top": 0.0,
"index": 2,
"version": 0
}
]