mikehaertl\pdftk\Pdf::execute PHP Method

execute() public method

You should probably never call this method unless you only need a temporary PDF file as result.
public execute ( ) : boolean
return boolean whether the command was executed successfully
    public function execute()
    {
        $command = $this->getCommand();
        if ($command->getExecuted()) {
            return false;
        }
        if ($this->_output === false) {
            $filename = null;
        } else {
            $filename = $this->_output ? $this->_output : (string) $this->getTmpFile();
        }
        if (!$command->execute($filename)) {
            $this->_error = $command->getError();
            if ($filename && !(file_exists($filename) && filesize($filename) !== 0 && $this->ignoreWarnings)) {
                return false;
            }
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param string|Pdf $name the PDF filename or Pdf instance to add for processing
  * @param string|null $handle one or more uppercase letters A..Z to reference this file later.
  * If no handle is provided, an internal handle is autocreated, consuming the range Z..A
  * @param string|null $password the owner (or user) password if any
  * @return Pdf the pdf instance for method chaining
  */
 public function addFile($name, $handle = null, $password = null)
 {
     if ($handle === null) {
         $handle = $this->nextHandle();
     }
     if ($name instanceof Pdf) {
         // Keep a reference to the object to prevent unlinking
         $this->_pdf = $name;
         if (!$name->getCommand()->getExecuted()) {
             // @todo: Catch errors!
             $name->execute();
         }
         $name = (string) $name->getTmpFile();
     }
     $this->getCommand()->addFile($name, $handle, $password);
     return $this;
 }