Convert PDF page-space points to bitmap pixel coordinates
Source:R/render.R
pdf_bitmap_from_page.RdInverse of pdf_bitmap_to_page(). Translates PDF user-space
points to pixel positions on a pdfium_bitmap (returned by
pdf_render_page()). Wraps FPDF_PageToDevice with the
render-geometry that produced the bitmap pre-populated from the
bitmap's attributes.
Arguments
- bitmap
A
pdfium_bitmapfrompdf_render_page().- x, y
Numeric vectors of PDF user-space coordinates. Recycled to a common length.
Value
A two-column tibble with integer columns x and y in
bitmap pixel coordinates (origin at the bitmap's top-left).
See also
pdf_bitmap_to_page() for the inverse,
pdf_page_to_device() for the underlying primitive.
Examples
fixture <- system.file("extdata", "fixtures", "shapes.pdf",
package = "pdfium"
)
if (nzchar(fixture)) {
doc <- pdf_doc_open(fixture)
bmp <- pdf_render_page(doc, dpi = 72)
# Map PDF page-space points (bottom-left origin) to bitmap pixels.
pdf_bitmap_from_page(bmp, x = c(0, 72), y = c(0, 72))
pdf_doc_close(doc)
}