The printArticleAsPdf
hook is triggered when an article should be exported as
PDF. It passes the article text and the article object as arguments and does not
expect a return value. Use it to override the internal PDF functionality.
Using the printArticleAsPdf
hook has been deprecated and will no longer work in Contao 5.0.
string $articleContent
The compiled article content.
\Contao\ModuleArticle $module
Instance of the \Contao\ModuleArticle
module responsible for producing the
front end output of an article.
// src/EventListener/PrintArticleAsPdfListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\ModuleArticle;
#[AsHook('printArticleAsPdf')]
class PrintArticleAsPdfListener
{
public function __invoke(string $articleContent, ModuleArticle $module): void
{
// Trigger your own PDF engine and exit
exit;
}
}