disabled
  7   	ˆl–äY>”Ši?u	@½p/ÜêbÑ¿�þZ”¥Y²ÈøÞ€uÒùÈ„p_ÇÆÅÄ ?÷     	package PDF::API2::Page;

use base 'PDF::API2::Basic::PDF::Pages';

use strict;
use warnings;

our $VERSION = '2.044'; # VERSION

use Carp;
use POSIX qw(floor);
use Scalar::Util qw(looks_like_number weaken);

use PDF::API2::Basic::PDF::Utils;
use PDF::API2::Content;
use PDF::API2::Content::Text;
use PDF::API2::Util;

my $page_sizes = {
    # Metric A
    '4a0'     => [ 4760, 6716 ],
    '2a0'     => [ 3368, 4760 ],
    'a0'      => [ 2380, 3368 ],
    'a1'      => [ 1684, 2380 ],
    'a2'      => [ 1190, 1684 ],
    'a3'      => [  842, 1190 ],
    'a4'      => [  595,  842 ],
    'a5'      => [  421,  595 ],
    'a6'      => [  297,  421 ],

    # Metric B
    '4b0'     => [ 5656, 8000 ],
    '2b0'     => [ 4000, 5656 ],
    'b0'      => [ 2828, 4000 ],
    'b1'      => [ 2000, 2828 ],
    'b2'      => [ 1414, 2000 ],
    'b3'      => [ 1000, 1414 ],
    'b4'      => [  707, 1000 ],
    'b5'      => [  500,  707 ],
    'b6'      => [  353,  500 ],

    # US
    'letter'  => [  612,  792 ],
    'legal'   => [  612, 1008 ],
    'ledger'  => [ 1224,  792 ],
    'tabloid' => [  792, 1224 ],
};

=head1 NAME

PDF::API2::Page - Methods to interact with individual pages

=head1 SYNOPSIS

    my $pdf = PDF::API2->new();

    # Add a page to a new or existing PDF
    my $page = $pdf->page();

    # Set the page size
    $page->size('letter');

    # Set prepress page boundaries
    $page->boundaries(media => '12x18', trim => 0.5 * 72);

    # Add an image
    my $image = $pdf->image('/path/to/file.jpg');
    $page->object($image, $x, $y, $w, $h);

    # Add textual content
    my $text = $page->text();

    # Add graphical content (paths and shapes)
    my $canvas = $page->graphics();

=cut

sub new {
    my ($class, $pdf, $parent, $index) = @_;
    my $self = {};

    $class = ref($class) if ref($class);
    $self = $class->SUPER::new($pdf, $parent);
    $self->{'Type'} = PDFName('Page');
    $self->proc_set(qw( PDF Text ImageB ImageC ImageI ));
    delete $self->{'Count'};
    delete $self->{'Kids'};
    $parent->add_page($self, $index);
    return $self;
}

sub coerce {
    my ($class, $pdf, $page) = @_;
    my $self = $page;
    bless $self, $class;
    $self->{' apipdf'} = $pdf;
    weaken $self->{' apipdf'};
    return $self;
}

# Deprecated.  Marking the page as dirty should only be needed in rare cases
# when the page hash is being edited directly rather than through the API.  In
# that case, the out_obj call can be made manually.  There's no reason (that I
# can think of) to have a specific call just (and only) for Page objects.
sub update {
    my $self = shift();
    $self->{' apipdf'}->out_obj($self);
    return $self;
}

=head1 METHODS

=head2 size

    # Set the page size using a common name
    $page->size('letter');

    # Set the page size using coordinates in points (X1, Y1, X2, Y2)
    $page->size([0, 0, 612, 792]);

    # Get the page coordinates in points
    my @rectangle = $page->size();

Set the physical page size (a.k.a. media box) when called with an argument.
See L</"Page Sizes"> below for possible values.  Returns the C<$page> object.

Returns the coordinates of the rectangle enclosing the physical page size when
called without arguments.

The size method is a convenient shortcut for setting the PDF's media box when
print-related page boundaries aren't required.  It's equivalent to the
following:

    # Set
    $page = $page->boundaries(media => $size);

    # Get
    @rectangle = $page->boundaries->{'media'}->@*;

=cut

sub size {
    my $self = shift();

    # Set
    if (@_) {
        return $self->boundaries(media => @_);
    }

    # Get
    my %boundaries = $self->boundaries();
    return @{$boundaries{'media'}};
}

=head2 boundaries

    # Set
    $page->boundaries(
        media => '13x19',
        bleed => [0.75 * 72, 0.75 * 72, 12.25 * 72, 18.25 * 72],
        trim  => 0.25 * 72,
    );

    # Get
    %boundaries = $page->boundaries();
    ($x1, $y1, $x2, $y2) = $page->boundaries('trim');

Set or replace all pre