NAME

PDF::Make - PDF generation, parsing, and editing

SYNOPSIS

# Markup API - a template and data in, PDF bytes out
use PDF::Make::Markup::Render;

my $pdf = PDF::Make::Markup::Render->render(<<'TPL', $data);
<doc page-size="A4" margin="36">
  <style h1="size:22;line-height:26" text="size:10" />
  <header>{% company.name %}</header>

  <h1>Invoice {% invoice.number %}</h1>
  <text>Payment due {% invoice.due %}</text>

  <table>
    <tr><th weight="4">Description</th><th align="right">Amount</th></tr>
    {% for l in invoice.lines %}
    <tr><td>{% l.name %}</td><td align="right">{% l.total | money %}</td></tr>
    {% end %}
  </table>

  <hr />
  <text align="right" size="12">Total due: <b>{% invoice.total | money %}</b></text>
</doc>
TPL

# High-level Builder API (recommended)
use PDF::Make::Builder;

PDF::Make::Builder->new(file_name => 'report.pdf')
    ->add_page(page_size => 'A4')
    ->title('Quarterly Report')
    ->author('Jane Smith')
    ->add_h1(text => 'Q4 Results')
    ->add_text(text => 'Revenue increased 15% year-over-year.')
    ->add_line(x => 72, ex => 523)
    ->add_image(image => 'chart.jpg', w => 400)
    ->add_outline('Q4 Results', page => 0)
    ->save;

# Low-level XS API (full control)
use PDF::Make::Document;
use PDF::Make::Canvas;
use PDF::Make::Page qw(:fonts);

my $doc  = PDF::Make::Document->new;
my $page = $doc->add_page(612, 792);
$page->add_std14_font('F1', HELVETICA);

my $c = PDF::Make::Canvas->new;
$c->BT->Tf('F1', 24)->Td(72, 700)->Tj('Hello, World!')->ET;
$page->set_content($c->to_bytes);

$doc->to_file('hello.pdf');

DESCRIPTION

The distribution provides three API layers:

PDF::Make::Markup::Render - Highest level: a document is a template and a hash of data, not a program. The markup is a small fixed grammar (headings, text, tables, rows, boxes, images) and the template syntax is Template::Stencil, so the layout lives in a file a designer can edit and the Perl only supplies the data. Compiles onto the Builder.
PDF::Make::Builder - High-level, chainable, Object::Proto-based API for common document creation tasks. Handles coordinate translation, page management, word-wrap, and font metrics automatically.
PDF::Make::Document / PDF::Make::Canvas - Low-level XS API that maps directly to PDF specification concepts. Gives full control over content streams, object graphs, and page structure.

MODULES

Core

PDF::Make::Document - Create and serialise PDF documents
PDF::Make::Page - Page objects with font and content management
PDF::Make::Canvas - Content stream builder (all PDF operators)
PDF::Make::Writer - Low-level PDF serialiser
PDF::Make::Arena - Memory arena for PDF object graphs
PDF::Make::Obj - PDF primitive wrappers (int, string, array, dict)

Parsing and Reading

PDF::Make::Parser - Parse existing PDF files
PDF::Make::Reader - Read page information from parsed PDFs
PDF::Make::Extract - Extract text, annotations, forms, and tables from PDF pages

Fonts and Images

PDF::Make::Font - Standard 14 and TrueType font handling
PDF::Make::Image - JPEG and PNG image embedding

Interactive Features

PDF::Make::Form - AcroForm interactive forms
PDF::Make::Field - Form field types (text, checkbox, radio, combo)

Document Features

PDF::Make::Layer - Optional Content Groups (layers/OCG)
PDF::Make::Attachment - Embedded file attachments
PDF::Make::Structure - Tagged PDF and accessibility (StructTree)
PDF::Make::Color - Color spaces (sRGB, Separation, CMYK)
PDF::Make::Watermark - Text and image watermarks, stamps
PDF::Make::Redaction - Content redaction and metadata sanitisation

Security

PDF::Make::Crypt - Encryption (RC4, AES-128, AES-256)
PDF::Make::Signature - Digital signatures (PKCS#12, X.509)

Output

PDF::Make::Linearization - Fast Web View (linearised PDF)

Markup (Template API)

PDF::Make::Markup::Render - Template and data in, PDF out
PDF::Make::Markup::Profile - The template profile (escaping on, fixed filters)
PDF::Make::Markup::Parse - Markup parser, errors carry line and column
PDF::Make::Markup::Style - Attribute and <style> declaration handling
PDF::Make::Markup::Build - Compiles a parsed tree onto the Builder

Builder (High-Level API)

PDF::Make::Builder - Chainable document builder
PDF::Make::Builder::Font - Font registry and metrics
PDF::Make::Builder::Page - Page state and layout
PDF::Make::Builder::Text - Word-wrapped text with alignment
PDF::Make::Builder::Image - Image placement
PDF::Make::Builder::TOC - Table of contents generation
PDF::Make::Builder::Shape::Line - Line drawing
PDF::Make::Builder::Shape::Box - Rectangle drawing
PDF::Make::Builder::Shape::Circle - Circle drawing
PDF::Make::Builder::Shape::Ellipse - Ellipse drawing
PDF::Make::Builder::Shape::Pie - Pie/arc sector drawing

FUNCTIONS

version()

my $v = PDF::Make::version();

Returns the libpdfmake version string.

DEPENDENCIES

  • Object::Proto - Call-checker-optimised accessors for Builder classes.

No other runtime dependencies. Template::Stencil is needed only to render a template through "render" in PDF::Make::Markup::Render; render_markup, which takes markup with no data in it, does not need it, and neither does anything else in the distribution.

SEE ALSO

PDF::Make::Markup::Render for the template API, and PDF::Make::Builder for the recommended high-level API.

Object::Proto

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.