Example #1
0
 /**
  * Adds a javascript form field.
  * @param $type (string) field type
  * @param $name (string) field name
  * @param $x (int) horizontal position
  * @param $y (int) vertical position
  * @param $w (int) width
  * @param $h (int) height
  * @param $prop (array) javascript field properties. Possible values are described on official Javascript for Acrobat API reference.
  * @protected
  * @author Denis Van Nuffelen, Nicola Asuni
  * @since 2.1.002 (2008-02-12)
  */
 protected function _addfield($type, $name, $x, $y, $w, $h, $prop)
 {
     if ($this->rtl) {
         $x = $x - $w;
     }
     // the followind avoid fields duplication after saving the document
     $this->javascript .= "if (getField('tcpdfdocsaved').value != 'saved') {";
     $k = $this->k;
     $this->javascript .= sprintf("f" . $name . "=this.addField('%s','%s',%u,[%F,%F,%F,%F]);", $name, $type, $this->PageNo() - 1, $x * $k, ($this->h - $y) * $k + 1, ($x + $w) * $k, ($this->h - $y - $h) * $k + 1) . "\n";
     $this->javascript .= 'f' . $name . '.textSize=' . $this->FontSizePt . ";\n";
     while (list($key, $val) = each($prop)) {
         if (strcmp(substr($key, -5), 'Color') == 0) {
             $val = TCPDF_COLORS::_JScolor($val);
         } else {
             $val = "'" . $val . "'";
         }
         $this->javascript .= 'f' . $name . '.' . $key . '=' . $val . ";\n";
     }
     if ($this->rtl) {
         $this->x -= $w;
     } else {
         $this->x += $w;
     }
     $this->javascript .= '}';
 }