hmm intresting, i am using mpdf, didnt know about this one.
Anyways, implementing "standalone" libraries has nothing to do with Phalcon, you have to implement them in your own way. Here are some code samples of my workers which are sending emails
$di->set('simpleView', function ($dir) use ($config) {
$view = new \Phalcon\Mvc\View\Simple();
$view->setViewsDir($dir);
$eventsManager = new EventsManager();
$view->registerEngines([
'.phtml' => function ($view, $di) {
$phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
return $phtml;
},
'.volt' => function ($view, $di) use ($config) {
$volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
$volt->setOptions([
'compileAlways' => true,
'compiledPath' => $config->voltCompileDir
]);
$compiler = $volt->getCompiler();
$compiler->addFunction("money_format", "money_format");
$compiler->addFunction("round", "round");
$compiler->addFunction("hashIds", function ($resolvedArgs, $exprArgs) {
return $this->getShared("hashIds")->encode($resolvedArgs);
});
return $volt;
}
]);
$eventsManager->attach("view:afterRender", function ($event, $view) {
$search = [
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
];
$replace = [
'>',
'<',
'\\1'
];
$view->setContent((string)preg_replace($search, $replace, $view->getContent()));
});
return $view;
});
//in the controller
$html = $this->simpleView->render("somevoltfile.volt", ['my-data' => "somevar" ... ]);
//create the pdf should be something like this
$dompdf = new Dompdf\Dompdf();
$dompdf->loadHtml($html);
$dompdf->render();
$output = $dompdf->output();
file_put_contents('/var/www/mysite/filename.pdf', $output);