When rotating pages by changing the Page Rotation metadata, the fields have the wrong position and wrong orientation.
Investigation: formalpdf renders rotated pages correctly as landscape. The ML model returns normalized coordinates (x_n, y_n) relative to that landscape image. But rect_for() converts using the raw mediabox as if the image were portrait. So scaling is wrong and the axes are transposed.
Example
Reproduce
- Original file with pages rotated in Mac Preview (p. 7-14): 2074.pdf
- File with incorrectly detected fields: 2074-form-output.pdf
- Run
commonforms 2074.pdf
When rotating pages by changing the Page Rotation metadata, the fields have the wrong position and wrong orientation.
Investigation: formalpdf renders rotated pages correctly as landscape. The ML model returns normalized coordinates (
x_n, y_n) relative to that landscape image. Butrect_for()converts using the raw mediabox as if the image were portrait. So scaling is wrong and the axes are transposed.Example
Reproduce
commonforms 2074.pdf