Yasin Yörük
Yasin Yörük

Reputation: 1539

TCPDF open links in new tab/window

How to open links in new tab/window which is in pdf document. I tried target="_blank" but it did not work. I was found javascript solution on the internet. But how I can use javascript in tcpdf.

I tried the following:

$text = 'bla bla bla bla bla bla bla bla<br>';
$url = "http://google.com";
$links = ' <a href="javascript:open_win('.$url.');">Click me</a> 
           <a href="'.$url.'" target="_blank">Click me</a> ';

$output = $text.$links; $pdf->writeHTML($output);

But it did not work.

Upvotes: 6

Views: 13122

Answers (3)

Tristanisginger
Tristanisginger

Reputation: 2683

In short it is not possible here is SO answer that clarifies.

https://stackoverflow.com/a/39763562/1695062

Upvotes: 0

EricEricson
EricEricson

Reputation: 19

you can open a the pdf by adding a target="_blank" in your form method

<form method="post" target="_blank">
...
</form>

Upvotes: 0

Krish
Krish

Reputation: 2670

use the below method

<a href="javascript: w=window.open('yoursite.com/LinkToThePDF.pdf'); w.print(); w.close(); ">​​​​​​​​​​​​​​​​​print pdf</a>

Upvotes: 1

Related Questions