/** * @param $html * @return File * @throws \Exception */ public function generate($html) { $tempName = md5(rand()); $htmlFile = new File(); $htmlFile->setPath(sprintf('%s/tmp/%s.html', APP_DIR, $tempName))->setContent($html); $pdfFile = new File(); $pdfFile->setName(sprintf('%s.pdf', $tempName))->setPath(sprintf('%s/tmp/%s.pdf', APP_DIR, $tempName))->setType('application/pdf'); exec(sprintf('%s %s %s', $this->getBinaryPath(), $htmlFile->getPath(), $pdfFile->getPath())); return $pdfFile; }