mikehaertl\pdftk\Pdf::getDataFields PHP Method

getDataFields() public method

public getDataFields ( boolean $utf8 = true ) : string | boolean
$utf8 boolean whether to dump the data UTF-8 encoded. Default is true.
return string | boolean data about the PDF form fields or false on failure
    public function getDataFields($utf8 = true)
    {
        $property = $utf8 ? '_dataFields_utf8' : '_dataFields';
        if ($this->{$property} === null) {
            $command = $this->getCommand();
            $command->setOperation($utf8 ? 'dump_data_fields_utf8' : 'dump_data_fields');
            if (!$command->execute()) {
                return false;
            } else {
                $this->{$property} = trim($command->getOutput());
            }
        }
        return $this->{$property};
    }

Usage Example

Exemplo n.º 1
0
 public function testCanGetDataFields()
 {
     $form = $this->getForm();
     $pdf = new Pdf($form);
     $data = $pdf->getDataFields();
     $this->assertInternalType('string', $data);
     $this->assertEquals($this->formDataFields, $data);
 }