NAME
PDF::Make::RenderPage - Render PDF pages to pixel buffers
SYNOPSIS
use PDF::Make::Reader;
use PDF::Make::RenderPage;
# Open a PDF
my $reader = PDF::Make::Reader->open('document.pdf');
# Get page dimensions
my ($width, $height) = PDF::Make::RenderPage::get_page_render_size(
$reader, 0, 150 # page 0 at 150 DPI
);
# Render the page
my $result = PDF::Make::RenderPage::render_page($reader, 0, {
dpi => 150,
background => 0xFFFFFFFF, # White background
antialias => 1,
});
# Access the rendered data
my $pixels = $result->{pixels}; # Raw RGBA data
my $width = $result->{width};
my $height = $result->{height};
# Render a region
my $region = PDF::Make::RenderPage::render_page_region(
$reader, 0,
100, 100, 200, 200, # x, y, w, h in PDF units
{ dpi => 150 }
);
DESCRIPTION
PDF::Make::RenderPage provides the render pipeline for converting PDF pages to rasterized pixel output. It integrates the content stream interpreter with the path rendering engine to produce accurate visual representations of PDF pages.
FUNCTIONS
get_page_render_size($reader, $page_num, $dpi)
Returns the pixel dimensions (width, height) that a page will have when rendered at the specified DPI.
render_page($reader, $page_num, \%options)
Render a page to a pixel buffer. Returns a hashref containing:
{
pixels => $raw_rgba_data,
width => $pixel_width,
height => $pixel_height,
render_time_ms => $milliseconds,
effective_dpi => $actual_dpi,
path_objects => $path_count,
text_objects => $text_count,
image_objects => $image_count,
error => $error_message, # if any
}
render_page_region($reader, $page_num, $x, $y, $w, $h, \%options)
Render only a portion of a page. Coordinates are in PDF user space units.
OPTIONS
- dpi
-
Dots per inch for rendering. Default is 72 (1:1 with PDF units).
- scale_mode
-
Scaling algorithm for images: SCALE_NEAREST, SCALE_BILINEAR, SCALE_BICUBIC.
- rotation
-
Page rotation: ROTATE_0, ROTATE_90, ROTATE_180, ROTATE_270.
- antialias
-
Enable antialiasing (1) or disable (0). Default is 1.
- background
-
Background color as 0xAARRGGBB. Default is white (0xFFFFFFFF).
- clip_x, clip_y, clip_w, clip_h
-
Render only a clipped region in pixel coordinates.
- render_text
-
Render text objects (1) or skip them (0). Default is 1.
- render_images
-
Render image XObjects (1) or skip them (0). Default is 1.
- render_vectors
-
Render vector paths (1) or skip them (0). Default is 1.
CONSTANTS
Scale Modes
SCALE_NEAREST = 0
SCALE_BILINEAR = 1
SCALE_BICUBIC = 2
Rotation
ROTATE_0 = 0
ROTATE_90 = 90
ROTATE_180 = 180
ROTATE_270 = 270
SEE ALSO
PDF::Make, PDF::Make::Reader, PDF::Make::Render
AUTHOR
LNATION <email@lnation.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.