When working with AI Builder and PDF documents, there's a difference in how the coordinate systems are set up. AI Builder uses a coordinate system where the origin (0,0) is at the top-left corner, with the x-axis increasing to the right and the y-axis increasing downwards. However, PDF documents typically have their origin at the bottom-left corner, with the x-axis increasing to the right and the y-axis increasing upwards.
So, if you get coordinates from AI Builder and want to position text accurately on a PDF, you need to convert those coordinates to match the PDF's coordinate system. The main thing you need to do is flip the y-coordinate. You can do this by subtracting the AI Builder y-coordinate from the total height of the PDF page or image area you're working with.
For example, let's say AI Builder gives you a y-coordinate of 100, and the image height is 1000. To get the corresponding y-coordinate in the PDF system, you'd do 1000 - 100 = 900. This flips the y-axis to match how PDFs work.
Now, there are a few other things to consider. You'll need to know the exact dimensions of the image area you're working with in AI Builder, so you can use those for the conversion. If the image dimensions in AI Builder and the PDF are different, you might need to apply scaling factors too.
Additionally, AI Builder's coordinate system is based on the top-left corner of the image it analyzes. So you can generally assume its origin is at (0,0) in that top-left corner.