Y-coordinates in PDFs
Posted: Sat Jul 13, 2019 12:20 pm
Is there a reason why you get coordinates from pdf.GetRects and pdf.GetPageLinks (and probably elsewhere too) so that origin is at bottom?
For example with this PDF: sample-link_1.pdf
And this code:
You get this output:
Top: 736 Bottom: 727
Top: 479 Bottom: 464
So, the top values are bigger than bottom values.
But one funny detail... I've found one PDF that does give the link (but not rects) values in different (more logical) order:
Top: 796 Bottom: 782
Top: 723 Bottom: 737
...but all the others so far have shown it like mentioned. Soo, I have to check in code which, top or bottom, is bigger... but any idea why it's like this?
For example with this PDF: sample-link_1.pdf
And this code:
Code: Select all
@REQUIRE "polybios", {Version=1, Revision=1}
pdf.OpenDocument(1, "sample-link_1.pdf")
pdf.LoadPage(1, 1, True)
t = pdf.GetRects(1, 1, 0, 3)
DebugPrint("Top:", Int(t[0].top), "Bottom:", Int(t[0].bottom))
t = pdf.GetPageLinks(1, 1)
DebugPrint("Top:", Int(t[0].top), "Bottom:", Int(t[0].bottom))
Top: 736 Bottom: 727
Top: 479 Bottom: 464
So, the top values are bigger than bottom values.
But one funny detail... I've found one PDF that does give the link (but not rects) values in different (more logical) order:
Top: 796 Bottom: 782
Top: 723 Bottom: 737
...but all the others so far have shown it like mentioned. Soo, I have to check in code which, top or bottom, is bigger... but any idea why it's like this?