public function pdf($config = [])
    {
        if (!isset($config['url']) && !isset($config['html'])) {
            throw new \Exception('URL or HTML in configuration required', 400);
        }
        $tempFile = null;
        if (!isset($config['pdf']['path'])) {
            $tempFile = tempnam(sys_get_temp_dir(), 'pdf-');
            $this->config['pdf']['path'] = $tempFile;
        }
        // default PDF configuration
        $this->config['pdf']['format'] = 'A4';
        $this->config['pdf']['printBackground'] = true;
        
        $this->config = self::merge($this->config, $config);
        $fullCommand = $this->path.' ' .$this->nodePath.' ' .$this->nodeBinary.' '
            .escapeshellarg($this->executable). ' ' .escapeshellarg(json_encode($this->config));
            
        if ($this->isDebug) {
            $fullCommand .= " 2>&1";
        }
        exec($fullCommand, $output, $returnVal);
        $result = [
            'ouput' => $output,
            'returnVal' => $returnVal
        ];
        if ($returnVal == 0 && isset($tempFile)) {
            $data = file_get_contents($this->config['pdf']['path']);
            unlink($this->config['pdf']['path']);
            return $data;
        }
        
        return $result;
    }
public function pdf($config = [])
    {
        if (!isset($config['url']) && !isset($config['html'])) {
            throw new \Exception('URL or HTML in configuration required', 400);
        }
        $tempFile = null;
        if (!isset($config['pdf']['path'])) {
            $tempFile = tempnam(sys_get_temp_dir(), 'pdf-');
            $this->config['pdf']['path'] = $tempFile;
        }
        // default PDF configuration
        $this->config['pdf']['format'] = 'A4';
        $this->config['pdf']['printBackground'] = true;
        
        $this->config = self::merge($this->config, $config);
        $fullCommand = $this->path.' ' .$this->nodePath.' ' .$this->nodeBinary.' '
            .escapeshellarg($this->executable). ' ' .escapeshellarg(json_encode($this->config));
            
        if ($this->isDebug) {
            $fullCommand .= " 2>&1";
        }
        exec($fullCommand, $output, $returnVal);
        $result = [
            'ouput' => $output,
            'returnVal' => $returnVal
        ];
        if ($returnVal == 0 && isset($tempFile)) {
            $data = file_get_contents($this->config['pdf']['path']);
            unlink($this->config['pdf']['path']);
            return $data;
        }
        
        return $result;
    }
public function pdf ( $ config = [ ] ) { if ( ! isset ( $ config [ 'url' ] ) && ! isset ( $ config [ 'html' ] ) ) { throw new \ Exception ( 'URL or HTML in configuration required' , 400 ) ; } $ tempFile = null ; if ( ! isset ( $ config [ 'pdf' ] [ 'path' ] ) ) { $ tempFile = tempnam ( sys_get_temp_dir ( ) , 'pdf-' ) ; $ this -> config [ 'pdf' ] [ 'path' ] = $ tempFile ; } // default PDF configuration $ this -> config [ 'pdf' ] [ 'format' ] = 'A4' ; $ this -> config [ 'pdf' ] [ 'printBackground' ] = true ; $ this -> config = self :: merge ( $ this -> config , $ config ) ; $ fullCommand = $ this -> path . ' ' . $ this -> nodePath . ' ' . $ this -> nodeBinary . ' ' . escapeshellarg ( $ this -> executable ) . ' ' . escapeshellarg ( json_encode ( $ this -> config ) ) ; if ( $ this -> isDebug ) { $ fullCommand .= " 2>&1" ; } exec ( $ fullCommand , $ output , $ returnVal ) ; $ result = [ 'ouput' => $ output , 'returnVal' => $ returnVal ] ; if ( $ returnVal == 0 && isset ( $ tempFile ) ) { $ data = file_get_contents ( $ this -> config [ 'pdf' ] [ 'path' ] ) ; unlink ( $ this -> config [ 'pdf' ] [ 'path' ] ) ; return $ data ; } return $ result ; }
Generate PDF file based on configuration.

@param array $config configuration for PDF generation, this will override default configuration.

Sample $config
```
$config = [
'html' => '<h1>Hello World</h1>',
'pdf' => [
'path' => '/tmp/test.pdf',
'margin' => [
'top' => '10mm',
'right' => '10mm',
'bottom' => '10mm',
'left' => '10mm',
]
]
];
```

1. Must set either $config['url'] or $config['html'], if both, will pick up html.
2. If $config['pdf']['path'] is set, will generate PDF file to the specific path,
otherwise, will return PDF data.

@return mixed property value
1. array $result when $config['pdf']['path'] is set or the `command` is not running successfully,
$result includes output of command and a return value, you can use $result['returnVal'] to check restult,
$result['returnVal'] == 0 means pdf is generated successfully, else find detailed error from $result['ouput'];
2. PDF data, this is returned only when $config['pdf']['path'] is not set.
Generate PDF file based on configuration .