예제 #1
0
 /**
  * @param File $file
  */
 public function __construct(File $file)
 {
     parent::__construct($file->getContent());
     $this->addHeader(sprintf('Content-Type: %s', $file->getType()));
     $this->addHeader(sprintf('Content-Length: %d', $file->getSize()));
     $this->addHeader(sprintf('Content-Disposition: attachment; filename="%s"', $file->getName()));
 }
예제 #2
0
 /**
  * @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;
 }