/**
  * Create a demo PDF and save it to the given filename
  *
  * @param string $filename the filename for the PDF
  */
 public function actionIndex($filename)
 {
     $pdf = new PdfFile();
     // We have to set some paths ...
     $pdf->baseViewPath = Yii::getPathOfAlias('ext.pdfable.pdfable.views');
     $pdf->layoutPath = Yii::getPathOfAlias('ext.pdfable.pdfable.views.layouts');
     $pdf->viewPath = Yii::getPathOfAlias('ext.pdfable.pdfable.views.demo');
     // ... and supply our custom CSS file
     $pdf->setOptions(array('user-style-sheet' => Yii::getPathOfAlias('ext.pdfable.pdfable.assets.css.pdf') . '.css'));
     $pdf->renderPage('invoice');
     $pdf->renderPage('page1');
     $pdf->renderPage('page2');
     $pdf->saveAs($filename);
 }
Exemple #2
0
 /**
  * @return PdfFile a new preconfigured PDF document
  */
 public function createPdf()
 {
     require_once __DIR__ . '/PdfFile.php';
     $pdf = new PdfFile($this->defaultPdfOptions, $this->defaultPdfPageOptions);
     $pdf->controller = $this->owner;
     $pdf->setOptions($this->getPdfOptions());
     $pdf->setPageOptions($this->getPdfPageOptions());
     return $pdf;
 }
Exemple #3
0
 /**
  * @return PdfFile a new preconfigured PDF document
  */
 public function createPdf()
 {
     Yii::import('ext.pdfable.PdfFile');
     $pdf = new PdfFile($this->defaultPdfOptions, $this->defaultPdfPageOptions);
     $pdf->controller = $this->owner;
     $pdf->setOptions($this->getPdfOptions());
     $pdf->setPageOptions($this->getPdfPageOptions());
     return $pdf;
 }