コード例 #1
0
ファイル: PDFTest.php プロジェクト: johncollinseu/php-pdf
 public function testInputSourceReturnsHTMLFileWhenLoadHtmlIsCalled()
 {
     $this->pdf->loadHTML('<b>foo bar</b>');
     $this->assertContains('.html', $this->call('getInputSource'));
 }
コード例 #2
0
 public function pdfAction()
 {
     $sm = $this->getServiceLocator();
     $companyService = $sm->get('Stjornvisi\\Service\\Company');
     /** @var  $companyDAO \Stjornvisi\Service\Company */
     $userService = $sm->get('Stjornvisi\\Service\\User');
     /** @var  $companyDAO \Stjornvisi\Service\User */
     $company = $companyService->get(14);
     array_walk($company->members, function ($member) use($userService) {
         $attendance = $userService->attendance($member->id);
         $member->attendance = count($attendance) <= 2 ? $attendance : array_slice($attendance, -2, 2, false);
     });
     $layout = new ViewModel(array('company' => $company));
     $layout->setTemplate('script');
     $phpRenderer = new \Zend\View\Renderer\PhpRenderer();
     $phpRenderer->setCanRenderTrees(true);
     $resolver = new \Zend\View\Resolver\TemplateMapResolver();
     $resolver->setMap(array('script' => __DIR__ . '/../../../view/pdf/company-report.phtml'));
     $phpRenderer->setResolver($resolver);
     $pdf = new \CanGelis\PDF\PDF('/usr/local/bin/wkhtmltopdf');
     $pdf->loadHTML($phpRenderer->render($layout))->save("out.pdf", new \League\Flysystem\Adapter\Local('/Users/einar/Desktop/'), true);
 }