Example #1
-1
 /**
  * {@inheritDoc}
  */
 public function generate($path, $html)
 {
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     if (null === $ext) {
         $path .= ".ext";
     } elseif ("pdf" !== $ext) {
         throw new InvalidArgumentException(sprintf("Your destination path must have a .pdf extension for conversion, '%s' passed.", $ext));
     }
     $pdf = new Pdf();
     $pdf->setBinary($this->_getBinDir() . 'wkhtmltopdf-' . $this->_getBinaryType());
     foreach ($this->_options as $key => $value) {
         $pdf->setOption($key, $value);
     }
     if (is_file($path)) {
         unlink($path);
     }
     // Strip out `@font-face{ ... }` style tags as these break the pdf
     $html = preg_replace('/@font-face{([^}]*)}/ms', '', $html);
     $pdf->generateFromHTML($html, $path);
     return new File($path);
 }