Question 


 Can I create custom PDF's in an Interaction?


Answer 


$t->toPDF()

$t->toPDF($options);

Description #

Like $t->createPDF(), This function is used to create a custom PDF to attach to an email within the custom code area of Blinkforms of Blinkforms.

$t->toPDF() however differs in you now can not only create custom PDF's in BlinkForms, you can now use them within mADL Interactions as well.

$t->toPDF() is also fully customisable and includes some new mADL constants for easier development.

Parameters #

An array of options now including the following arrays and settings.

  • base64 : (boolean) to return file as base64 decoded string (default is false)

  • page : An array containing the following parameters

    • orientation (string) page orientation. Possible values are (case insensitive):

      • P  for Portrait (default).

      • L  for Landscape

      • '' (empty string) for automatic orientation

    • unit : (string) User measure unit. Possible values are:

      • pt: point

      • mm: millimeter (default)

      • cm: centimeter

      • in: inch

    • size : (string) page size

    • margins :  (array) for top, right, bottom and left margins (case sensitive)

      • t : (int) default is 27

      • r : (int) default is 15

      • b : (int) default is 30

      • l : (int) default is 15

    • imageScaling : (string) default is 1

    • family : (string) : default is arial unicode (to allow multi-language)

    • border : (array) Indicates if borders must be drawn around the cell. The value can be a number:

      • 0: no border (default)

      • 1: frame

    • Or a string containing some or all of the following characters (in any order):

      • L: left

      • T: top

      • R: right

      • B: bottom

    • Or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))

    • align : (string) Allows to center or align the text. Possible values are:

      • L : left align

      • C : center

      • R : right align

      • '' : empty string : left for LTR or right for RTL

  • meta : An array containing the following parameters

    • creator : (string) page creator

    • author : (string) page author

    • title :  (string) page title

    • subject : (string) page subject

    • keywords : (string) page keywords

  • security : An array containing the following parameters

  • (only applied if [page][secure] = true

    • permissions : (Array) the set of permissions (specify the ones you want to block):

      • print : Print the document;

      • modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';

      • copy : Copy or otherwise extract text and graphics from the document;

      • annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);

      • fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;

      • extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);

      • assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;

      • print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.

      • owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.

    • userPassword : (String)

    • ownerPassword : (String) owner password. If not specified, a random value is used.

    • mode : (int) encryption strength:

      • 0 = RC4 40 bit

      • 1 = RC4 128 bit

      • 2 = AES 128 bit

      • 3 = AES 256 bit

    • pubKeys : (string)

  • header: An array containing your header styling and html code

    • margin : (array) use the same parameters as page:margin

    • border : (array) use the same parameters as page:border

    • font : (array) font parameters used in header

      • family : (string) default is arial unicode (to allow multi-language)

      • style

      • size

    • html : (string) containing your header html code

  • footer : An array containing your footer styling and html code

    • margin : (array) use the same parameters as page:margin

    • border : (array) use the same parameters as page:border

    • font : (array) font parameters used in footer

      • family : (string) default is arial unicode (to allow multi-language)

      • style

      • size

    • html : (string) containing your footer html code

  • body : An array containing your body styling and html code

    • margin : (array) use the same parameters as page:margin

    • border : (array) use the same parameters as page:border

    • font : (array) font parameters used in body

      • family : (string) default is arial unicode (to allow multi-language)

      • style

      • size

    • align : (array) use the same parameters as page:alignment

    • html : (string) containing your body html code

Additional parameters for the pdf component arrays when used in BlinkForms #

If you are using this function in the custom code area of BlinkForms you can still use the following methods in the PDF boy array

  • exclude_fields : An array of your forms fields you want in exclude.

  • include_fields : An array of fields you want in include. Note: exclude_fields have higher precedence than include_fields

  • {_BLINK_DATA_TABLE_} : A constant which when added to the body->html array will display all your BlinkForm fields in the standard BlinkForms PDF table layout

Leaving the include_fields & exclude_fields arrays blank will include all fields on the form.

Additional constants for the pdf  #

 Header/Footer:

  • {_BLINK_PAGES_} : A constant which when added to the header or footer array will display total number of pages

  • {_BLINK_PAGE_NO_} : A constant which when added to the header or footer array will display the current page number 

Return values#

None

An object to attach to an email

$pdf_content = $t->toPDF($options);


Examples #


Click here to view an example on Github: https://github.com/blinkmobile/examples/blob/master/madl%20interaction/Custom%20PDF/%24t-%3EtoPDF.php