I am using TCPDF to create simple pdf document.
I am creating a page and adding link using below code
$pdf->addTOCPage();
$link = $pdf->AddLink();
$pdf->SetLink($link, 0, -1);
Now link is set successfull.But to navigate to that page what should I add ? I tried below code , but it does nothing,
<a href="#Whattoaddhere" style="color:blue;">Return to TOC</a>
// Create a fixed link to the first page using the * character
$index_link = $pdf->AddLink();
$pdf->SetLink($index_link, 0, '*1');
$pdf->Cell(0, 10, 'Link to INDEX', 0, 1, 'R', false, $index_link);
http://www.tcpdf.org/examples/example_045.phps
update - refer to this function addHtmlLink() in tcpdf library. You can add a internal link through this
$pdf->addHtmlLink('#'.$index_link, 'hello');
where 'hello' begin the name of anchor and and first param being identifier to the link.
In your case
$pdf->addHtmlLink('#'.$link, 'Whatever you like to name it');
$html = '<a href="#'.$link.'" style="color:blue;">link name</a>';
$pdf->writeHTML($html, true, false, true, false, '');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With