Internal link in tcpdf

I use TCPDF to create a simple pdf document.

I create a page and add a link using the code below

$pdf->addTOCPage(); $link = $pdf->AddLink(); $pdf->SetLink($link, 0, -1); 

Now the link is set successfully. But to go to this page, what should I add? I tried the code below but does nothing,

<a href="#Whattoaddhere" style="color:blue;">Return to TOC</a>

+4
source share
2 answers
  // 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 addHtmlLink () function in the tcpdf library. You can add an internal link through

  $pdf->addHtmlLink('#'.$index_link, 'hello'); 

where 'hello' begins the binding name and the first parameter is the link identifier.

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, ''); 
+2
source

I am trying to add an internal link in tcpdf using the following code:

 $pdf->addHtmlLink('#demotest1', 'Demo Test1'); $pdf->addHtmlLink('#demotest2', 'Demo Test2'); $html = '<a href="#demotest1">Demo Test1 Whatever you like to name it</a>'; $pdf->writeHTML($html, true, false, true, false, ''); $html = '<a href="#demotest2">Demo Test2 Whatever you like to name it</a>'; $pdf->writeHTML($html, true, false, true, false, ''); 

But that does not work.

My requirement is that if you click Demo Test1, it should go to Demo Test 1.

How would this happen? Please someone can help me. thanks

0
source

All Articles