Diego Pita Silva
Diego Pita Silva

Reputation: 1

Hellosign conversion old system cordinates

I'm wanting to take advantage of the fields created by Hellosign that can be downloaded by the get / template /:id api, to assemble a pdf here with the document, but I saw that in the return from the API they use an old 80 DPI system where I only have o X, Y, Width, Height, I wanted to convert it to a 72 dpi format how do I do this conversion to inject this with a PDBox for example?

GET https://[api key]:@api.hellosign.com/v3/template/[:template_id] "form_fields": [ { "api_id": "b65e03_10", "name": "DepartmentA", "type": "checkbox", "x": 117, "y": 19, "width": 15, "height": 15, "required": false, "group": "group1" }, { "api_id": "b65e03_11", "name": "DepartmentB", "type": "checkbox", "x": 118, "y": 41, "width": 15, "height": 15, "required": false, "group": "group1" }, { "api_id": "0ec7a7_1", "name": "VendorName", "type": "text", "x": 160, "y": 141, "width": 80, "height": 30, "required": true, "group": null }, { "api_id": "0ec7a7_2", "name": "VendorTitle", "type": "text", "x": 160, "y": 181, "width": 80, "height": 30, "required": true, "group": null }, { "api_id": "0ec7a7_3", "name": "ManagerName", "type": "text", "x": 160, "y": 221, "width": 80, "height": 30, "required": true, "group": null }, { "api_id": "0ec7a7_4", "name": "ManagerTitle", "type": "text", "x": 160, "y": 251, "width": 80, "height": 30, "required": true, "group": null }, { "api_id": "0ec7a7_5", "name": "DateSigned", "type": "date_signed", "x": 523, "y": 28, "width": 105, "height": 16, "required": true, "group": null } ]

I want inject fields in PDBox in document.

Upvotes: 0

Views: 122

Answers (1)

BarbaraW
BarbaraW

Reputation: 24

I believe this was also discussed on a support ticket but I'm also posting the answer here in case anyone else would like to know about this. Here are the calculations our team has come up to be able to get the closest as possible to converting the coordinates. The below might differentiate depending on the file size, but I'm basing this on a US Standard Landscape Letter Document , which has the following dimension : 8.5 x 11, which is 612 x 792 DPI.

For the x coordinates:

Those should be multiplied by 0.9 (0.9 is the result when dividing 72/80) - 100 (because the old coordinates for the x will start in 100).

Example: Let's try an example with "x:"450.

(450 - 100) * 0.9 = 315. So the x coordinate in the new system should be 315

For the y coordinates: Those should also be multiplied by 0.9 (0.9 is the result when dividing 72/80), then minus the page size depending on which page these fields are. For US standard letter the page size is 792. If the fields is on the third page for example, then you'd have the same calculation - the page size for the number of pages you'd want to remove.

Example:

Let's try an example with "y": 1734

First thing we need to confirm in this case is in which page this field is, since we don't have the page parameter on the old system.In order to know that, we must divide the y coordinate for the page size. So in this example should be 1734/792, and the result is 2.1893939394. With that we know that field should be on the second page.

After that, we can check the new coordinates:

1734 * 0.9 = 1,560.6 (which we can round for 1561)

1561 - 792 (since we need to subtract an entire page) = 769

If the field is on the first page, in this case it's only necessary to multiply the value of y for 0.9.

In this case: 218 * 0.9 - 196.1 (rounding for 196)

Adding the page parameter

With the new coordinates, a page parameter should be specified. You can check the page for each field by dividing the y coordinate/ page size.

Subtracting the signer index In the Get template response, the signer index will start at 1. To add the form_fields_per_document, we're expecting the signer index to start at 0, so just subtract 1 from all signers from the response.

Example old system: "signer": "1", Example new system: "signer": "0",

The above will also depend on the file size. Form_fields_per_document coordinate system is designed to use with US Letter-sized documents, and the following formula to convert fields will not work in all circumstances - however, it may be useful as a starting point if you are trying to place fields on a non-standard document and are willing to experiment. We have instructions on the article below for another type of document sizing https://faq.hellosign.com/hc/en-us/articles/217115577-How-to-use-the-Form-Fields-Per-Document-parameter.

Upvotes: 0

Related Questions