PageTree
Description
This role contains methods for querying and manipulating page tree nodes in a PDF.
Page Fragments
This class includes the methods:
`page-fragment` - create a detached page
`pages-fragment` - create a detached page sub-tree
`global-resources-scope - get or set shared resources across pages
These stand-alone fragments aim to be thread-safe to support parallel construction of pages. The final PDF assembly needs to be synchronous.
use PDF::Content::Page;
use PDF::Content::PageTree;
use lib 't';
use PDFTiny;
my PDFTiny $pdf .= new;
my PDF::Content::Page @pages;
@pages = (1..20).hyper(:batch(1)).map: -> $page-num {
my PDF::Content::Page:D $page = PDF::Content::PageTree.page-fragment;
$page.text: {
.text-position = 50, 400;
.say: "Page $page-num";
}
$page.finish;
$page;
}
$pdf.add-page($_) for @pages;
Methods
This is an advanced setting that sets up a global resource dictionary. Any pages that are then directly created via `add-page` will use the global resources dictionary for fonts and XObjects, etc.
This may be of use in certain specialized cases, such as when the PDF is being used as a resource library. The resources will be able to be accessed later by opening the PDF, but without needing to go to any particular page.