PageTree

[Raku PDF Project] / [PDF-Content Module] / PDF::Content :: PageTree

methods related to page tree nodes

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

method page-fragment

method page-fragment() returns PDF::Content::Page

produce a single page fragment, not attached to any PDF

method pages-fragment

method pages-fragment() returns PDF::Content::PageNode

produce a page-tree fragment, not attached to any PDF

method global-resources-scope

method global-resources-scope() returns Bool

get or set global-resources-scope

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.

method add-page

method add-page(
    PDF::Content::Page:D $page = Code.new
) returns PDF::Content::Page

add new last page

method add-pages

method add-pages(
    PDF::Content::PageTree:D $pages = Code.new
) returns PDF::Content::PageTree

append page subtree

method page

method page(
    Int $page-num where { ... } = 0
) returns PDF::Content::Page

$.page(0?) - adds a new page

method page

method page(
    Int $page-num where { ... }
) returns PDF::Content::Page

traverse page tree

method page-index

method page-index() returns Array

build flattened index of indirect references to pages

method pages

method pages() returns Array

return all leaf pages for this page tree. or sub-tree

method delete-page

method delete-page(
    Int $page-num where { ... }
) returns PDF::Content::Page

delete page from page tree

method page-count

method page-count() returns UInt

return the number of pages

PDF::Content v0.9.11

PDF content related classes; including text, images, fonts and graphics

Authors

  • David Warring

License

Artistic-2.0

Dependencies

Base64::NativeColorCompress::Zlib::RawFont::AFM:ver<1.24.10+>Native::PackingMethod::AlsoJSON::FastPDF:ver<0.6.8+>PDF::Grammar:ver<0.3.2+>

Test Dependencies

Provides

  • PDF::Content
  • PDF::Content::API
  • PDF::Content::Canvas
  • PDF::Content::Color
  • PDF::Content::Font
  • PDF::Content::Font::CoreFont
  • PDF::Content::Font::Enc::Glyphic
  • PDF::Content::Font::Enc::Type1
  • PDF::Content::Font::Encoder
  • PDF::Content::Font::Encodings
  • PDF::Content::FontObj
  • PDF::Content::Image
  • PDF::Content::Image::GIF
  • PDF::Content::Image::JPEG
  • PDF::Content::Image::PDF
  • PDF::Content::Image::PNG
  • PDF::Content::Interface
  • PDF::Content::Matrix
  • PDF::Content::Ops
  • PDF::Content::Page
  • PDF::Content::PageNode
  • PDF::Content::PageTree
  • PDF::Content::ResourceDict
  • PDF::Content::Resourced
  • PDF::Content::Tag
  • PDF::Content::Text::Block
  • PDF::Content::Text::Box
  • PDF::Content::Text::Line
  • PDF::Content::Text::Style
  • PDF::Content::XObject
  • X::PDF::Content

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.