Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _destination_position(pdf, destination):
"""
Gives a tuple (page, column, -y, x) representing the position of the
NamedDestination
This representation is useful for sorting named destinations and
assumes the text has at most 2 columns
"""
pagewidth = pdf.getPage(
pdf.getDestinationPageNumber(destination)
).cropBox.lowerRight[0]
if not destination.left or not destination.top:
raise IncompleteCoordinatesError(destination)
# assuming max 2 columns
column = (2 * destination.left) // pagewidth
return (pdf.getDestinationPageNumber(destination),
column, -destination.top, destination.left)