The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

PDF::Imposition::Schema - Base class for the imposition schemas.

SYNOPSIS

Please don't use this class directly, but use PDF::Imposition or the right schema class, which inherit from this (which in turns defines the shared methods). This class does not do anything useful by itself, but only provides some shared methods.

    use PDF::Imposition;
    my $imposer = PDF::Imposition->new(file => "test.pdf",
                                       # either use 
                                       outfile => "out.pdf",
                                       # or suffix
                                       suffix => "-2up"
                                      );
    $imposer->impose;
or 

    use PDF::Imposition;
    my $imposer = PDF::Imposition->new();
    $imposer->file("test.pdf");
    
    $imposer->outfile("out.pdf");
    # or
    $imposer->suffix("-imp");

    $imposer->impose;
  

METHODS

Constructor

new(file => "file.pdf", suffix => "-imp", cover => 0, [...])

Costructor. Options should be passed as list. The options are the same of the read-write accessors describe below, so passing $self->file("file.pdf") is exactly the same of passing $self->new(file => "file.pdf").

Read/write accessors

All the following accessors accept an argument, which sets the value.

file

Unsurprisingly, the input file, which must exist.

outfile

The destination file of the imposition. You may prefer to use the suffix method below, which takes care of the filename.

suffix

The suffix of the file. By default, '-imp', so test.pdf imposed will be saved as 'test-imp.pdf'. If test-imp.pdf already exists, it will be replaced merciless.

cover

This option is ignored for 2x4x2 and 2side schemas. Often it happens that we want the last page of the pdf to be the last one on the physical booklet after folding. If cover is set to a true value, the last page of the logical pdf will be placed on the last page of the last signature.

Individual schema implementations are in charge to check and act on this setting.

Es.

  $imposer->cover(1);

Internal accessors

The following methods are used internally but documented for schema's authors.

CAM::PDF is used to get the properties, and PDF::API2 to arrange the pages. CAM::PDF is also used to convert PDF 1.6-1.5 to PDF v1.4, which it's the only version PDF::API2 understands.

dimensions

Returns an hashref with the original pdf dimensions in points.

  { w => 800, h => 600 }

orig_width

orig_height

total_pages

Returns the number of pages

in_pdf_obj

Internal usage. It's the PDF::API2 object used as source.

out_pdf_obj

Internal usage. The PDF::API2 object used as output.

get_imported_page($pagenumber)

Retrieve the page form object from the input pdf to the output pdf, and return it. The method return undef if the page is out of range.

impose

Do the job and leave the output in $self->outfile, cleaning up the internal objects.

SEE ALSO

PDF::Imposition