package PDF::Make::Page;

use strict;
use warnings;

our $VERSION = '0.13';

# Load the XS code from PDF::Make
use PDF::Make ();

# XS bindings provide:
#   add_font($name, $base_font)    - add a font to the page resources
#   add_std14_font($name, $id)     - add a standard 14 font
#   set_content($bytes)            - set page content stream
#   DESTROY()                      - cleanup (page owned by document)

# Standard 14 font constants
use constant {
    TIMES_ROMAN           => 0,
    TIMES_BOLD            => 1,
    TIMES_ITALIC          => 2,
    TIMES_BOLDITALIC      => 3,
    HELVETICA             => 4,
    HELVETICA_BOLD        => 5,
    HELVETICA_OBLIQUE     => 6,
    HELVETICA_BOLDOBLIQUE => 7,
    COURIER               => 8,
    COURIER_BOLD          => 9,
    COURIER_OBLIQUE       => 10,
    COURIER_BOLDOBLIQUE   => 11,
    SYMBOL                => 12,
    ZAPFDINGBATS          => 13,
};

use Exporter 'import';
our @EXPORT_OK = qw(
    TIMES_ROMAN TIMES_BOLD TIMES_ITALIC TIMES_BOLDITALIC
    HELVETICA HELVETICA_BOLD HELVETICA_OBLIQUE HELVETICA_BOLDOBLIQUE
    COURIER COURIER_BOLD COURIER_OBLIQUE COURIER_BOLDOBLIQUE
    SYMBOL ZAPFDINGBATS
);
our %EXPORT_TAGS = (
    fonts => [qw(
        TIMES_ROMAN TIMES_BOLD TIMES_ITALIC TIMES_BOLDITALIC
        HELVETICA HELVETICA_BOLD HELVETICA_OBLIQUE HELVETICA_BOLDOBLIQUE
        COURIER COURIER_BOLD COURIER_OBLIQUE COURIER_BOLDOBLIQUE
        SYMBOL ZAPFDINGBATS
    )],
);

1;

__END__

=head1 NAME

PDF::Make::Page - PDF page object

=head1 SYNOPSIS

    use PDF::Make::Document;
    use PDF::Make::Page qw(:fonts);
    use PDF::Make::Canvas;

    my $doc = PDF::Make::Document->new;
    my $page = $doc->add_page(612, 792);  # Letter size

    # Add fonts to the page
    $page->add_std14_font('F1', HELVETICA);
    $page->add_font('F2', 'MyFont');

    # Create content with a Canvas
    my $canvas = PDF::Make::Canvas->new;
    $canvas->BT
           ->Tf('F1', 12)
           ->Td(72, 720)
           ->Tj('Hello, World!')
           ->ET;

    # Set the page content
    $page->set_content($canvas->to_bytes);

    # Write the PDF
    my $bytes = $doc->to_bytes;

=head1 DESCRIPTION

C<PDF::Make::Page> represents a page in a PDF document. Pages are created
via C<< PDF::Make::Document->add_page() >> and are owned by the document.

=head1 METHODS

=head2 add_font

    $page->add_font($name, $base_font);

Add a font resource to the page. C<$name> is the resource name (e.g., 'F1')
used in content streams, and C<$base_font> is the font name.

=head2 add_std14_font

    use PDF::Make::Page qw(:fonts);
    $page->add_std14_font('F1', HELVETICA);

Add one of the PDF standard 14 fonts to the page. These fonts are guaranteed
to be available in all PDF readers without embedding.

=head2 set_content

    $page->set_content($bytes);

Set the page content stream. C<$bytes> should be valid PDF content stream
operators, typically generated by C<PDF::Make::Canvas>.

=head1 CONSTANTS

The following constants are available for the standard 14 fonts:

=head2 Serif fonts (Times)

=over 4

=item * C<TIMES_ROMAN>

=item * C<TIMES_BOLD>

=item * C<TIMES_ITALIC>

=item * C<TIMES_BOLDITALIC>

=back

=head2 Sans-serif fonts (Helvetica)

=over 4

=item * C<HELVETICA>

=item * C<HELVETICA_BOLD>

=item * C<HELVETICA_OBLIQUE>

=item * C<HELVETICA_BOLDOBLIQUE>

=back

=head2 Monospace fonts (Courier)

=over 4

=item * C<COURIER>

=item * C<COURIER_BOLD>

=item * C<COURIER_OBLIQUE>

=item * C<COURIER_BOLDOBLIQUE>

=back

=head2 Symbol fonts

=over 4

=item * C<SYMBOL>

=item * C<ZAPFDINGBATS>

=back

=head1 SEE ALSO

L<PDF::Make::Document>, L<PDF::Make::Canvas>

=cut
