PDF Functions

PDF functionality to MADL which is accessible in the custom code area of BlinkForms Builder or can be used within a mADL Interaction.

$t->createPDF( )

The createPDF() MADL function returns a string for use in email, fetches, etc. 
The following sample code shows the available options: ($options is optional)

Parameters #An array of options including the following.
authorA String. Sets the author of the pdf
headerA String. The header of the pdf.
description

A String. The description of the pdf.

footerA String. The footer of the pdf.
header_imageA place holder for the header image.
styleAttach a custom CSS.
include_fields

 An array of fields you want in include.

 //exclude_fields have higher precedence than include_fields

 exclude_fields.An array of fields you want in exclude.
base64_encodeBoolean. To set base64 encoding on images. (Optional).

Note

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

Return Values   

 
$pdf_content = $t->createPDF($options);
An object to attach to an email
$t->createPDF( ) Example
$options = array(
        'author' => 'Testing',
        'header' => 'Header',
        'description' => 'Description',
        'footer' => 'Footer',
        'header_image' => '',
        'style' => ' th {
                        background-color: #C2CAD1;
                        color: #000000;
                        font-weight: bold;
                    }
                    .odd {
                        background-color: #C1E5FF;
                        color: #000000;
                    }
                    .even {
                        background-color: #E8E8E8;
                        color: #000000;
                    }
                    .heading{
                        background-color: #336699;
                        color: #FFFFFF;
                    }
                    .required {
                        color: #cc0000;
                        font-weight: bold;
                        font-size: 30px;
                    }',
        'include_fields' => array(), //exclude_fields have higher precedence than include_fields
        'exclude_fields' => array(
                        'Field1',
                        'SubformField2' => array(
                                'SField1', 
                                'SSubField2' => array(
                                        'SSField1'
                                        )
                                )
                    ),
        'base64_encode' => false
    );

//function call
//the argument is optional
$pdf_content = $t->createPDF($options);

$from ="bmp@blinkmobile.com.au";
$to = "you@youremail.com.au";
$subject = "After";
$body = "see attachments";

$t->AddStringAttachment($pdf_content, "MyCustomPdf.pdf", "base64", "application/pdf");
$t->email($to, $subject, $body, $from);

Base64 Workaround

Any fields you wish to be excluded from the output simple add them to the exclude_fields array. Exclude_fields have higher precedence than include_fields. $pdf_content then can be added to an email attachment or sent as part of a web service. The workaround if base64 strings are required is

$t->AddStringAttachment($pdf_content, "NameYourPDF.pdf", "base64", "application/pdf");
Or if the attachment is in a separate location use
AddAttachment($path, $name, $encoding = 'base64', $type = 'application/octet-stream')

 

$t->toPDF( )

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.

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

Parameters #An array of options now including the following arrays and settings.Possible values are (case insensitive):
base64(boolean) to return file as base64 decoded string (default is false) 
pageAn 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..
  • 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.
  • L : left align
  • C : center
  • R : right align
  • '' : empty string : left for LTR or right for RTL
metaAn 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 
securityAn 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)

 
headerAn 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

 
footerAn 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

 
bodyAn 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

 

 

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

Parameters #An array of options including the following.
include_fields

An array of your forms fields you want in exclude.

 exclude_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

Note

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


 

Additional constants for the pdf

Parameters # 
{_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   

 
$pdf_content = $t->toPDF($options);
An object
$t->toPDF( ) Example
$defaults = array(
        'base64' => false,
        'page' => array(
            'orientation' => 'P',
            'unit' => 'mm',
            'size' => 'A4',
            'unicode' => true,
            'encoding' => 'UTF-8',
            'margins' => array(
                't' => 27,
                'r' => 15,
                'b' => 30,
                'l' => 15
            ),
            'imageScaling' => 1.5,
            'secure' => false,
        ),
        'meta' => array(
            'creator' => '',
            'author' => '',
            'title' => '',
            'subject' => '',
            'keywords' => ''
        ),
        'security' => array(
            'permissions' => array(
                'print', 
                'modify', 
                'copy', 
                'annot-forms', 
                'fill-forms', 
                'extract', 
                'assemble', 
                'print-high'
            ),
            'userPassword' => '',
            'ownerPassword' => null,
            'mode' => 0,
            'pubKeys' => null
        ),
        'header' => array(
            'margin' => 5,
            'border' => 'B',
            'font' => array(
                'family' => 'arialuni', 
                'style' => '', 
                'size' => 10
            ),
            'html'=> '<table style="font-family:Arial, Helvetica, sans-serif;" width="100%"  border="0">
<tr>
  <td width="30%"><a href="http://www.blinkmobile.com.au"><img  width="200" src="http://s3.amazonaws.com/au.com.blinkmobile.bmp2.conference.conf-1/signature/Bmlogo.jpg" alt="www.blinkmobile.com.au" /></a></td>
  <td valign="middle"><h1 style="color: #336699; margin: 0px; padding: 0px;">BlinkMobile Interactive</h1><font style="font-weight:bold; color: #A0A0A0; margin: 0px; padding: 0px;">PDF DEMO</font>
  </td>
</tr>
</table>'
        ),
        'footer' => array(
            'margin' => 30,
            'border' => 'T',
            'font' => array(
                'family' => 'arialuni', 
                'style' => '', 
                'size' => 10
            ),
            'html'=> '<table style="font-family:Arial, Helvetica, sans-serif;" width="100%">
      <tr>
        <td rowspan="2" valign="middle" >{_BLINK_PAGE_NO_}/{_BLINK_PAGES_}</td>
        <td>
            <strong>Ashish Tilara</strong><br>
            <em>Web Developer</em><br>
            ashish@blinkmobile.com.au
        </td>
      </tr>
      <tr>
        <td>
        <img height="20" width="20" src="http://s3.amazonaws.com/au.com.blinkmobile.bmp2.conference.conf-1/signature/in.png"/> <img height="20" width="20" src="http://s3.amazonaws.com/au.com.blinkmobile.bmp2.conference.conf-1/signature/tw.png"/> <img height="20" width="20" src="http://s3.amazonaws.com/au.com.blinkmobile.bmp2.conference.conf-1/signature/yt.png"/> <img height="20" width="20" src="http://s3.amazonaws.com/au.com.blinkmobile.bmp2.conference.conf-1/signature/fb.png"/>
        </td>
      </tr>
    </table>'
        ),
        'body' => array(
            'html' => '<html>
    <head>
        <style type="text/css">

            .info {
                margin: 5px 0px;
                padding:5px 5px 5px 5px;
                background-repeat: no-repeat;
                background-position: 10px center;
                font-weight: bold;
                color: #00529B;
                background-color: #E6F5FC;
            }
            .success {
                margin: 5px 0px;
                padding:5px 5px 5px 5px;
                background-repeat: no-repeat;
                background-position: 10px center;
                font-weight: bold;
                color: #4F8A10;
                background-color: #F1FAE1;
            }
            .warning {
                margin: 5px 0px;
                padding:5px 5px 5px 5px;
                background-repeat: no-repeat;
                background-position: 10px center;
                font-weight: bold;
                color: #9F6000;
                background-color: #FAF4DC;
            }
            .error {
                margin: 5px 0px;
                padding:5px 5px 5px 5px;
                background-repeat: no-repeat;
                background-position: 10px center;
                font-weight: bold;
                color: #D8000C;
                background-color: #FFEDF2;
            }
            .processing {
                margin: 5px 0px;
                padding:5px 5px 5px 5px;
                background-repeat: no-repeat;
                background-position: 10px center;
                font-weight: bold;
                color: #73706F;
                background-color: #F2F2F2;
            }
        </style>
    </head>
<body>

<div class="error">ERROR</div>
<div class="info">INFO</div>
<div class="success">SUCCESS</div>
<div class="warning">WARNING</div>
<div class="processing">PROCESSING</div>

<br /><br /><br />
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 
<em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> 
<em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 
<br /> <br />
<em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> 
<em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 
<em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> 
<em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em>
<br /><br /><br />
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 
<em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> 
<em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 
<br /> <br />
<em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> 
<em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 
<em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> 
<em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em>
<br /><br /><br />

<div class="error">ERROR</div>
<div class="info">INFO</div>
<div class="success">SUCCESS</div>
<div class="warning">WARNING</div>
<div class="processing">PROCESSING</div>


<body>
</html>',
            'font' => array(
                'family' => 'arialuni', 
                'style' => '', 
                'size' => 10
            ),
            'align' => ''
        )
    );


$from ="bmp@blinkmobile.com.au"; $to = "you@youremail.com.au";
$subject = "After";
$body = "see attachments";
$pdf_content = $t->toPDF($defaults);

$t->AddStringAttachment($pdf_content, "MyCustomPdf.pdf", "base64", "application/pdf");
$t->email($to, $subject, $body, $from);

echo $t->result;