Rand Stats

Pod::To::PDF::Lite

zef:dwarring

TITLE

Pod::To::PDF::Lite

SUBTITLE

Pod to PDF draft renderer

Description

Renders Pod to PDF draft documents via PDF::Lite.

Usage

From command line:

$ raku --doc=PDF::Lite lib/To/Class.rakumod --save-as=To-Class.pdf

From Raku:

use Pod::To::PDF::Lite;

=NAME
foobar.pl

=SYNOPSIS
    foobar.pl <options> files ...

pod2pdf($=pod).save-as: "foobar.pdf";

Exports

class Pod::To::PDF::Lite;
sub pod2pdf; # See below

From command line:

$ raku --doc=PDF::Lite lib/to/class.rakumod --save-as=class.pdf

From Raku code, the pod2pdf function returns a PDF::Lite object which can be further manipulated, or saved to a PDF file.

use Pod::To::PDF::Lite;
use PDF::Lite;

=NAME
foobar.raku

=SYNOPSIS
    foobarraku <options> files ...

my PDF::Lite $pdf = pod2pdf($=pod);
$pdf.save-as: "foobar.pdf"

Command Line Options:

--save-as=pdf-filename

File-name for the PDF output file. If not given, the output will be saved to a temporary file. The file-name is echoed to stdout.

--width=n

Page width in points (default: 592)

--height=n

Page height in points (default: 792)

--margin=n --margin-left=n --margin-right=n --margin-top=n --margin-bottom=n

Page margins in points (default: 20)

--page-numbers

Output page numbers (format Page n of m, bottom right)

--page-style

-raku --doc=PDF::Lite lib/to/class.rakumod --page-style='margin:10px 20px; width:200pt; height:500pt" --save-as=class.pdf

Perform CSS @page like styling of pages. At the moment, only margins (margin, margin-left, margin-top, margin-bottom, margin-right) and the page width and height can be set. The optional CSS::Properties module needs to be installed to use this option.

--async

Perform asynchronous processing. This may be useful for larger PoD documents, that have multiple sections, seperated by level-1 headers, or titles.

Subroutines

sub pod2pdf()

raku sub pod2pdf( Pod::Block $pod, ) returns PDF::Lite;

Renders the specified Pod to a PDF::Lite object, which can then be further manipulated or saved.

PDF::Lite :$pdf

An existing PDF::Lite object to add pages to.

UInt:D :$width, UInt:D :$height

The page size in points (default 612 x 792).

UInt:D :$margin

The page margin in points (default 20).

Hash :@fonts

By default, Pod::To::PDF::Lite uses core fonts. This option can be used to preload selected fonts.

Note: PDF::Font::Loader must be installed, to use this option.

use PDF::Lite;
use Pod::To::PDF::Lite;
need PDF::Font::Loader; # needed to enable this option

my @fonts = (
    %(:file<fonts/Raku.ttf>),
    %(:file<fonts/Raku-Bold.ttf>, :bold),
    %(:file<fonts/Raku-Italic.ttf>, :italic),
    %(:file<fonts/Raku-BoldItalic.ttf>, :bold, :italic),
    %(:file<fonts/Raku-Mono.ttf>, :mono),
);

PDF::Lite $pdf = pod2pdf($=pod, :@fonts);
$pdf.save-as: "pod.pdf";

Bool :$async

Process a document in asynchronous batches.

This is only useful for a large Pod document that has multiple sections, each beginning with a title, or level-1 heading.

Restrictions

PDF::Lite minimalism, including:

See Also