src/Pdf.php
private function fillText($page, $block, $value, $fillOpts = array())
	{
		$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $block['Name'], $value);
		$p = $this->p;
		$opts['fillcolor'] = $fillOpts['fillcolor'];
		if (!empty($block['Custom']['PDFlib:field:type'])
			&& in_array($block['Custom']['PDFlib:field:type'], array('checkbox','radiobutton'))
		) {
			$field_type		= $block['Custom']['PDFlib:field:type'];
			$value_block	= $block['Custom']['PDFlib:field:value'];
			#$this->debug->log('type', $field_type);
			#$this->debug->log('value_block', $value_block);
			#$this->debug->log('value', $value);
			if ($field_type == 'checkbox') {
				$opts = array_merge($opts, $fillOpts['checkbox_opts']);
				#$this->debug->log('checkbox_opts', $opts);
				if ($value == $value_block || is_array($value) && in_array($value_block, $value)) {
					$value = $fillOpts['checkbox_value'];
				}
			} else {
				$opts = array_merge($opts, $fillOpts['radio_opts']);
				#$this->debug->log('radio_opts', $opts);
				if ($value == $value_block) {
					$value = $fillOpts['radio_value'];
				}
			}
			if (!$value) {
				$opts['textformat'] = null;
				$value = ' ';	 // gives the border
			}
		} else {
			$opts = array_merge($opts, $fillOpts['text_opts']);
		}
		/*
			@todo - better determination of if font is embedded or avail -> better fallback choice
		*/
		/*
		$fontname = !empty($opts['fontname'])
			? $opts['fontname']
			: $block['fontname'];
		if ( !in_array($fontname, $this->embeddedFonts) ) {
			$this->debug->info(font not embedded', $fontname);
			$opts['fallbackfonts'] = '{{fontname=Courier encoding=unicode}}';
		}
		*/
		// $opts['fontname'] = 'Courier';
		$this->debug->log($block['Name'], $value, $this->stringifyOpts($opts));
		$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
		if ($ret == 0) {
			// try again with a different font
			$opts['fontname'] = 'Courier';
			$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
		}
		$this->debug->groupEnd();
	}
private function fillText($page, $block, $value, $fillOpts = array())
	{
		$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $block['Name'], $value);
		$p = $this->p;
		$opts['fillcolor'] = $fillOpts['fillcolor'];
		if (!empty($block['Custom']['PDFlib:field:type'])
			&& in_array($block['Custom']['PDFlib:field:type'], array('checkbox','radiobutton'))
		) {
			$field_type		= $block['Custom']['PDFlib:field:type'];
			$value_block	= $block['Custom']['PDFlib:field:value'];
			#$this->debug->log('type', $field_type);
			#$this->debug->log('value_block', $value_block);
			#$this->debug->log('value', $value);
			if ($field_type == 'checkbox') {
				$opts = array_merge($opts, $fillOpts['checkbox_opts']);
				#$this->debug->log('checkbox_opts', $opts);
				if ($value == $value_block || is_array($value) && in_array($value_block, $value)) {
					$value = $fillOpts['checkbox_value'];
				}
			} else {
				$opts = array_merge($opts, $fillOpts['radio_opts']);
				#$this->debug->log('radio_opts', $opts);
				if ($value == $value_block) {
					$value = $fillOpts['radio_value'];
				}
			}
			if (!$value) {
				$opts['textformat'] = null;
				$value = ' ';	 // gives the border
			}
		} else {
			$opts = array_merge($opts, $fillOpts['text_opts']);
		}
		/*
			@todo - better determination of if font is embedded or avail -> better fallback choice
		*/
		/*
		$fontname = !empty($opts['fontname'])
			? $opts['fontname']
			: $block['fontname'];
		if ( !in_array($fontname, $this->embeddedFonts) ) {
			$this->debug->info(font not embedded', $fontname);
			$opts['fallbackfonts'] = '{{fontname=Courier encoding=unicode}}';
		}
		*/
		// $opts['fontname'] = 'Courier';
		$this->debug->log($block['Name'], $value, $this->stringifyOpts($opts));
		$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
		if ($ret == 0) {
			// try again with a different font
			$opts['fontname'] = 'Courier';
			$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
		}
		$this->debug->groupEnd();
	}
private function fillText ( $ page , $ block , $ value , $ fillOpts = array ( ) ) { $ this -> debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ , $ block [ 'Name' ] , $ value ) ; $ p = $ this -> p ; $ opts [ 'fillcolor' ] = $ fillOpts [ 'fillcolor' ] ; if ( ! empty ( $ block [ 'Custom' ] [ 'PDFlib:field:type' ] ) && in_array ( $ block [ 'Custom' ] [ 'PDFlib:field:type' ] , array ( 'checkbox' , 'radiobutton' ) ) ) { $ field_type = $ block [ 'Custom' ] [ 'PDFlib:field:type' ] ; $ value_block = $ block [ 'Custom' ] [ 'PDFlib:field:value' ] ; #$this->debug->log('type', $field_type); #$this->debug->log('value_block', $value_block); #$this->debug->log('value', $value); if ( $ field_type == 'checkbox' ) { $ opts = array_merge ( $ opts , $ fillOpts [ 'checkbox_opts' ] ) ; #$this->debug->log('checkbox_opts', $opts); if ( $ value == $ value_block || is_array ( $ value ) && in_array ( $ value_block , $ value ) ) { $ value = $ fillOpts [ 'checkbox_value' ] ; } } else { $ opts = array_merge ( $ opts , $ fillOpts [ 'radio_opts' ] ) ; #$this->debug->log('radio_opts', $opts); if ( $ value == $ value_block ) { $ value = $ fillOpts [ 'radio_value' ] ; } } if ( ! $ value ) { $ opts [ 'textformat' ] = null ; $ value = ' ' ; // gives the border } } else { $ opts = array_merge ( $ opts , $ fillOpts [ 'text_opts' ] ) ; } /*
			@todo - better determination of if font is embedded or avail -> better fallback choice
		*/ /*
		$fontname = !empty($opts['fontname'])
			? $opts['fontname']
			: $block['fontname'];
		if ( !in_array($fontname, $this->embeddedFonts) ) {
			$this->debug->info(font not embedded', $fontname);
			$opts['fallbackfonts'] = '{{fontname=Courier encoding=unicode}}';
		}
		*/ // $opts['fontname'] = 'Courier'; $ this -> debug -> log ( $ block [ 'Name' ] , $ value , $ this -> stringifyOpts ( $ opts ) ) ; $ ret = $ p -> fill_textblock ( $ page , $ block [ 'Name' ] , $ value , $ this -> stringifyOpts ( $ opts ) ) ; if ( $ ret == 0 ) { // try again with a different font $ opts [ 'fontname' ] = 'Courier' ; $ ret = $ p -> fill_textblock ( $ page , $ block [ 'Name' ] , $ value , $ this -> stringifyOpts ( $ opts ) ) ; } $ this -> debug -> groupEnd ( ) ; }
fill text block

@param integer $page     page
@param array   $block    block
@param string  $value    value
@param array   $fillOpts options

@return void
fill text block