Я использую плагин под названием Spiritix (https://github.com/spiritix/php-chrome-html2pdf) для создания chromepdf на платформе Symfony. Я получаю pagenumber
на headerTemplate
и footerTemplate
с использованием класса pageNumber
. Мои требованияэто получить номер pagen для части тела pdf. Есть ли какой-нибудь возможный способ?
Моя функция контроллера PDF
/**
* Function to view the contact of a club or federation.
*
* @return Json array
*/
public function viewspiritixpdfAction(Request $request)
{
$input = new StringInput();
$converter = new Converter($input, new EmbedOutput());
$html = $this->renderView('ClubadminContactBundle:ContactList:pdftest.html.twig', [
'title' => "Welcome to our PDF Test"
]);
$header = $this->renderView('ClubadminContactBundle:ContactList:pdftestheader.html.twig', [
]);
$footer = $this->renderView('ClubadminContactBundle:ContactList:pdftestfooter.html.twig', [
]);
$converter->setOptions([
'displayHeaderFooter'=> true,
'headerTemplate'=> $header,
'footerTemplate'=> $footer,
'margin'=> [
'top'=> "100px",
'bottom'=> "100px",
'right'=>'20px',
'left'=>'20px'
]
]);
$input->setHtml($html);
$output = $converter->convert();
$output->embed('html.pdf');
}
pdftest.html.twig
{% for i in 0..20 %}
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.</p>
{% endfor %}
На pdftest.html.twig мне нужно условие, что если pagenumber равен 2, то рендеринг изображения.