hankivy / text2pdf2

An enhanced version of text2pdf, as in the PDF::API2 perl module at https://cpan.org
GNU General Public License v3.0
0 stars 0 forks source link

No support for media size by name #7

Open hankivy opened 5 years ago

hankivy commented 5 years ago

The following paper size method is not supported. (See PDF::API2 in CPAN.)

$page->mediabox $alias

Examples: $pdf->mediabox($name) $pdf->mediabox($w, $h) $pdf->mediabox($llx, $lly, $urx, $ury)

All of the above sets the global mediabox, or page size.

More specific examples: $pdf = PDF::API2->new(); $pdf->mediabox('A4'); ... $pdf->saveas('our/new.pdf');

$pdf = PDF::API2->new(); $pdf->mediabox(595, 842); ... $pdf->saveas('our/new.pdf');

$pdf = PDF::API2->new; $pdf->mediabox(0, 0, 595, 842); ...

The supported name values, aliases, are '4A0', '2A0', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', '4B0', '2B0', 'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'LETTER', 'BROADSHEET', 'LEDGER', 'TABLOID', 'LEGAL', 'EXECUTIVE', and '36X36'. It would be nice to add portrait/landscape support.

It is not expected to require changing paper size in the middle of building a PDF file.

Support could be added as additional option values in the command line.

  1. Design - Offer changes to documentation.
    • Checkpoint with the owner.
  2. Create text file for testing various page sizes. 2A. Include printed material, text and/or images that demonstrate the width and length of the page. 2B. Include text that explains the expected results.
  3. Error checking - Demonstrate error handling with unsupported page size aliases. 3A. Create a shell script that has demonstrates the above.
    • Checkpoint once with the owner.
  4. Test, debug, and correct until the text file and the code are good.
    • Checkpoint and release with the owner.
PhilterPaper commented 3 years ago

You can't change page size in the middle of a page, but you can change on a new page (the document is a mixture of page sizes, defaulting to whatever was set in the overall document, which in turn defaults to US Letter). Also, you can call mediabox() with no parameters to be told what the current page dimensions are. I know that works in PDF::Builder; I think it's also implemented in PDF::API2.