I am using a plugin named Spiritix(https://github.com/spiritix/php-chrome-html2pdf) for generating a chromepdf on symfony framework.I am getting the pagenumber
on the headerTemplate
and footerTemplate
using the class pageNumber
.
My Requirement is to get pagenumber on the body part of the pdf.Is there any possible way exists?
My Pdf Controller Function
/**
* 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 %}
On the pdftest.html.twig i need a condition that if pagenumber is 2 then render a image.