Convert device (screen) coordinates to PDF page coordinates
Source:R/api_completion.R
pdf_device_to_page.RdWraps FPDF_DeviceToPage. Given a rendering window of size
(size_x, size_y) pixels at top-left (start_x, start_y) with
rotation rotate, maps the device pixel (device_x, device_y) to
a point in PDF user-space (points).
Arguments
- page
A
pdfium_pagefrompdf_page_load().- start_x, start_y
Integer — device-pixel position of the display area's top-left.
- size_x, size_y
Integer — pixel size of the rendering window.
- rotate
Integer —
0,1,2, or3(clockwise quarter turns). Same convention as PDFium's other rendering functions.- device_x, device_y
Integer — the pixel to convert.
Details
Useful when a downstream consumer reports a click position in pixels
(e.g. from a Shiny clickOpts event) and you want to translate it
back to PDF coordinates for hit-testing against page objects.
See also
pdf_page_to_device() for the inverse.