pdf_functions.php
Table of Contents
Functions
- get_pdf_template_path() : string
- Returns the path to a pdf template
- generate_pdf() : bool
- Takes an HTML template suitable for HTML2PDF library and generates a PDF file if successfull
- get_template_path() : string
- Returns the path to any template in the system.
- process_template() : string
- Function used to process a template
- process_if_statements() : string
- Process a string (mainly HTML) which contains if statement placeholders and return the processed string
- resolve_pdf_language() : string
- Function to convert the user's language into an HTML2PDF supported language.
- get_pdf_templates() : mixed
- Returns an array of available PDF template names *
Functions
get_pdf_template_path()
Returns the path to a pdf template
get_pdf_template_path(string $resource_type[, string $template_name = '' ]) : string
Parameters
- $resource_type : string
-
ID of the resource type
- $template_name : string = ''
-
Known template name already found in the array
Return values
stringgenerate_pdf()
Takes an HTML template suitable for HTML2PDF library and generates a PDF file if successfull
generate_pdf(string $html_template_path, string $filename[, array<string|int, mixed> $bind_placeholders = array() ][, bool $save_on_server = false ][, array<string|int, mixed> $pdf_properties = array() ]) : bool
Parameters
- $html_template_path : string
-
HTML template path
- $filename : string
-
The file name of the generated PDF file. If this is an actual path, and $save_on_server = true, it will be save on the server
- $bind_placeholders : array<string|int, mixed> = array()
-
A map of all the values that are meant to replace any placeholders found in the HTML template
- $save_on_server : bool = false
-
If true, PDF file will be saved to the filename path
- $pdf_properties : array<string|int, mixed> = array()
-
Properties of the PDF file (e.g. author, title, font, margins)
Return values
boolget_template_path()
Returns the path to any template in the system.
get_template_path(string $template_name, string $template_namespace) : string
Returns the path to any templates in the system as long as they are saved in the correct place:
- /templates (default - base templates)
- /filestore/system/templates (custom templates) Templates will be structured in folders based on features (e.g templates/contact_sheet/ will be used for any templates used for contact sheets)
Parameters
- $template_name : string
-
Template names should contain the extension as well (e.g. template_1.php / template_1.html)
- $template_namespace : string
-
The name by which multiple templates are grouped together
Return values
stringprocess_template()
Function used to process a template
process_template(string $template_path[, array<string|int, mixed> $bind_placeholders = array() ]) : string
Process template and bind any placeholders. The template should contain (if needed) PHP statements which will will be processed through this function.
Parameters
- $template_path : string
-
The full path to the location of the template (as returned by get_template_path())
- $bind_placeholders : array<string|int, mixed> = array()
-
A map of all the values that are meant to replace any placeholders found in the template
Return values
stringprocess_if_statements()
Process a string (mainly HTML) which contains if statement placeholders and return the processed string
process_if_statements(string $original_string, array<string|int, mixed> $bind_params) : string
Handles [%if var is set%] [%endif%] type of placeholders
Parameters
- $original_string : string
-
Full string containing placeholders
- $bind_params : array<string|int, mixed>
-
A map of all the values that are meant to replace any placeholders found in the HTML template
Return values
stringresolve_pdf_language()
Function to convert the user's language into an HTML2PDF supported language.
resolve_pdf_language() : string
Scans the HTML2PDF locale folder to create a list of supported languages to compare against the set user language. Also resolves dialects when possible. Fallback set to 'en'.
Return values
stringget_pdf_templates()
Returns an array of available PDF template names *
get_pdf_templates(string $template_namespace) : mixed
Parameters
- $template_namespace : string
-
The name by which multiple templates are grouped together e.g. contact_sheet