I have found a lot of information about page numbers in the footer for TCpdf, but I haven't found the solution to my specific problem.
My problem: A user can add a content type with : image, page number, title and orientation. The page number is needed, because the content is created when an image is received. So this is not in chronological order. An image can be added for page 20, while later on, an image that should be on page 2 is send. So as solution I added the possibility to add page number as field in the content type.
when the content type is created, the full pdf is again generated. But how can I set the page to the inserted page?
The solution I had was to disable the footer, and add my own line when adding the page. But when trying to create the table of contents, it takes the last page number and keeps repeating the last number. pagetitle1.....................40 pagetitle2.....................40 ...
my code for when each page is created ( where I thought I could add a setPage($number)), but this gave the error: Wrong page number on setPage() function
foreach ($nodes as $node) {
$title = $node->title;
$image = $node->field_tune['und'][0];
$image_orientation = $node->field_orientatie['und'][0]['value'];
$author = $node->field_composer['und'][0]['value'];
$page = $node->field_page['und'][0]['value'];
$orientation = ($image_orientation === 'Landscape' ) ? 'L' : 'P';
// add a page
$pdf->AddPage($orientation, 'A4', FALSE, TRUE);
//Here I added the code to set page number
//$pdf->setPage($page); --> this gave the error.
//But after further checking, this wasn't something to set
//pagenumber, but to go back to the defined page.
$pdf->Bookmark($title, 0, 0, '', 'B', array(0,64,128));
$html = theme('html_content_type_theme', [
'image' => theme('image_style', [
'style_name' => 'styled_image',
'path' => $image_uri,
]),
'orientation' => $orientation,
'title' => $title,
'author' => $author,
]);
// output the HTML content
$pdf->writeHTML($html, TRUE, TRUE, TRUE, FALSE, '');
$pdf->SetY(-15);
$pdf->SetFont('helvetica', '', 10);
//Here I create my custom footer to see the correct page
$pdf->Cell(0, 10, 'Ypres surrey Pipes & drums', 0, FALSE, 'C', 0, '', 0, FALSE, 'T', 'C');
$pdf->Cell(0, 10, $page, 0, FALSE, 'T', 0, '', 0, FALSE, 'T', 'C');
}
Another question: every content can be created by a custom author. How can I add the author name to the footer? ( Solution now: Is to add the author also as custom line in the html, not in the footer )