Professional Documents
Culture Documents
php
//============================================================+
// File name : example_014.php
// Begin : 2008-03-04
// Last Update : 2013-05-14
//
// Description : Example 014 for TCPDF class
// Javascript Form and user rights (only works on Adobe Acrobat)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com LTD
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Creates an example PDF TEST document using TCPDF
* @package com.tecnick.tcpdf
* @abstract TCPDF - Example: Javascript Form and user rights (only works on Adobe
Acrobat)
* @author Nicola Asuni
* @since 2008-03-04
* @group javascript
* @group form
* @group pdf
*/
// set margins
$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->setHeaderMargin(PDF_MARGIN_HEADER);
$pdf->setFooterMargin(PDF_MARGIN_FOOTER);
// ---------------------------------------------------------
// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+
$pdf->setFont('helvetica', '', 10, '', false);
// add a page
$pdf->AddPage();
/*
It is possible to create text fields, combo boxes, check boxes and buttons.
Fields are created at the current position and are given a name.
This name allows to manipulate them via JavaScript in order to perform some
validation for instance.
*/
// First name
$pdf->Cell(35, 5, 'First name:');
$pdf->TextField('firstname', 50, 5);
$pdf->Ln(6);
// Last name
$pdf->Cell(35, 5, 'Last name:');
$pdf->TextField('lastname', 50, 5);
$pdf->Ln(6);
// Gender
$pdf->Cell(35, 5, 'Gender:');
$pdf->ComboBox('gender', 30, 5, array(array('', '-'), array('M', 'Male'),
array('F', 'Female')));
$pdf->Ln(6);
// Drink
$pdf->Cell(35, 5, 'Drink:');
//$pdf->RadioButton('drink', 5, array('readonly' => 'true'), array(), 'Water');
$pdf->RadioButton('drink', 5, array(), array(), 'Water');
$pdf->Cell(35, 5, 'Water');
$pdf->Ln(6);
$pdf->Cell(35, 5, '');
$pdf->RadioButton('drink', 5, array(), array(), 'Beer', true);
$pdf->Cell(35, 5, 'Beer');
$pdf->Ln(6);
$pdf->Cell(35, 5, '');
$pdf->RadioButton('drink', 5, array(), array(), 'Wine');
$pdf->Cell(35, 5, 'Wine');
$pdf->Ln(6);
$pdf->Cell(35, 5, '');
$pdf->RadioButton('drink', 5, array(), array(), 'Milk');
$pdf->Cell(35, 5, 'Milk');
$pdf->Ln(10);
// Newsletter
$pdf->Cell(35, 5, 'Newsletter:');
$pdf->CheckBox('newsletter', 5, true, array(), array(), 'OK');
$pdf->Ln(10);
// Address
$pdf->Cell(35, 5, 'Address:');
$pdf->TextField('address', 60, 18, array('multiline'=>true, 'lineWidth'=>0,
'borderStyle'=>'none'), array('v'=>'Lorem ipsum dolor sit amet, consectetur
adipiscing elit.', 'dv'=>'Lorem ipsum dolor sit amet, consectetur adipiscing
elit.'));
$pdf->Ln(19);
// Listbox
$pdf->Cell(35, 5, 'List:');
$pdf->ListBox('listbox', 60, 15, array('', 'item1', 'item2', 'item3', 'item4',
'item5', 'item6', 'item7'), array('multipleSelection'=>'true'));
$pdf->Ln(20);
// E-mail
$pdf->Cell(35, 5, 'E-mail:');
$pdf->TextField('email', 50, 5);
$pdf->Ln(6);
$pdf->setX(50);
// Reset Button
$pdf->Button('reset', 30, 10, 'Reset', array('S'=>'ResetForm'),
array('lineWidth'=>2, 'borderStyle'=>'beveled', 'fillColor'=>array(128, 196, 255),
'strokeColor'=>array(64, 64, 64)));
// Submit Button
$pdf->Button('submit', 30, 10, 'Submit', array('S'=>'SubmitForm',
'F'=>'http://localhost/printvars.php', 'Flags'=>array('ExportFormat')),
array('lineWidth'=>2, 'borderStyle'=>'beveled', 'fillColor'=>array(128, 196, 255),
'strokeColor'=>array(64, 64, 64)));
// ---------------------------------------------------------
//============================================================+
// END OF FILE
//============================================================+