MIDDAG for Moodle

pdftk_adapter

Infrastructure service to handle PDF manipulations using PDFTk.

Wrapper around mikehaertl/php-pdftk.

Table of Contents

Properties

$binary_path  : null|string

Methods

get_instance()  : Pdf
Get a configured instance of the PDFTk wrapper.
is_available()  : bool
Check if PDFTk is available and executable.
uncompress_content()  : string
Uncompress a PDF file stream.
is_executable_path()  : bool
Verify if a path exists and is executable.
resolve_binary_path()  : string|null
Resolve the path to the PDFTk binary.

Properties

$binary_path

private static null|string $binary_path = null

Cache for the resolved binary path

Methods

get_instance()

Get a configured instance of the PDFTk wrapper.

public static get_instance([null|array<string|int, mixed>|string $pdf_path = null ]) : Pdf
Parameters
$pdf_path : null|array<string|int, mixed>|string = null

path to PDF file or array of paths

Tags
throws
RuntimeException

if PDFTk is not available

Return values
Pdf

is_available()

Check if PDFTk is available and executable.

public static is_available() : bool
Return values
bool

uncompress_content()

Uncompress a PDF file stream.

public static uncompress_content(string $content) : string

Useful for parsing PDF content.

Parameters
$content : string

Raw PDF content

Tags
throws
Exception
Return values
string

Uncompressed PDF content

is_executable_path()

Verify if a path exists and is executable.

private static is_executable_path(string $path) : bool
Parameters
$path : string
Return values
bool

resolve_binary_path()

Resolve the path to the PDFTk binary.

private static resolve_binary_path() : string|null

Priority:

  1. Moodle Config (local_middag | pdftk_path)
  2. Local bin folder (legacy support)
  3. System PATH (where/which).
Return values
string|null

        
On this page

Search results