Linetext positions in percentage?

Hi, I see that the JSON results are divided by linetext and you provide coordinates (top, left) and width and height ll in pixels.

However, since I don’t know the size, in pixels, of the document, it’s hard to calculate where I should get what text to saved in a structured way. I would think that providing top, left, width, and height as
percentages would be more appropriate.

How other users are handling that?

Or how can I get the height and width of the document, so I can make those calculations?

What documents do you send? PNG? JPG? PDF?

I sent PNG and JPG documents

Here the returned coordinates are exactly the x/y pixels in the PNG/JPG files.

size, in pixels, of the document

This is the size of the images that you send. This works well for me.

Can you explain how you parse the values to variables.

I created a template JSON file from one document and I created a transform (translate) rule in which I get the most at left Line and most Top Line, as well as the maxLeft value for a line and the maxTop value too.

Using those, I created the following interpolation:
const diffX = maxLeft - globalLeft
const diffY = maxTop - globalTop

and on a loop I calculate
const factorX = (docVars[key].left - globalLeftModel)/diffXModel
const calcLeft = diffX * factorX + globalLeft

      const factorY = (docVars[key].top - globalTopModel)/diffYModel
      const calcTop = diffY * factorY + globalTop

where docVars is a JSON template as

const docVars = {"restriccion_movilidad": {"left": 31 , "top": 45},
                    "blindaje": {"left": 415, "top": 45}, 
                    "potencia": {"left": 527, "top": 45},
                    "declaracion": {"left": 32, "top": 101},
                    "ie": {"left": 382, "top": 98, "elem": 0},
                    "fecha_import": {"left": 382, "top": 98, "elem": 1},
                    "puertas": {"left": 604, "top": 100},
                    "limitacion_a_la_propiedad": {"left": 32, "top": 180},
                    "fecha_matricula": {"left": 32, "top": 248},
                    "fecha_exp": {"left": 242, "top": 248},
                    "fecha_vencimiento": {"left": 480, "top": 248},
                    "organismo_transito": {"left": 31, "top": 321},
                    "id": {"left": 376, "top": 555},
                    "minLeft": 31,
                    "diffX": 596

So, docVars[key].left for the first element would be 31 for (key) restriccion_movilidad and so on.
diffXModelis the at most left value on the whole template, and diffXModel is the highest left value on the template - diffXModel

calcLeft and calcTop are the interpolated values for the image I am processing at a given times.
Then, I iterate to the Lines and see which values are close to those calcLeft and calcTop.

It works more or less, but it isn’t very precise.

Anyone has a better approach?