TCPDF open links in new tab/window
Asked Answered
S

3

6

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.

Solidary answered 1/4, 2013 at 11:49 Comment(8)
show me you code and what have you done so far?Erratum
$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);Karonkaross
I cant give break for lines. It's looking complicated. Problem; I have 2 links in pdf but these are not opens in new window. I tried javascript and target="_blank"Karonkaross
Is it okay for you if it accomplished by html or you must need a javascript solution?Erratum
I prefer HTML solution. But If not, I can use javascript.Karonkaross
Do you see this #15524680Blockbuster
@namjoo I have tried. The JavaScript opens the target, but again in the same tab/window.Sulfuric
@SarahTrees i tried this and it worked. <a href="a.pdf" target="_blank" rel="rel">link</a>Blockbuster
E
1

use the below method

<a href="javascript: w=window.open('yoursite.com/LinkToThePDF.pdf'); w.print(); w.close(); ">​​​​​​​​​​​​​​​​​print pdf</a>
Erratum answered 1/4, 2013 at 12:18 Comment(4)
I know using javascript normally. How can I add functions into TCPDF ? That's the point of my problem.Karonkaross
<a href="javascript: w=window.open('yoursite.com/LinkToThePDF.pdf'); w.print(); w.close(); ">​​​​​​​​​​​​​​​​​print pdf</a>Erratum
@YasinYörük : If this solves ur problem mark it as answer. Then only this question will close.Erratum
I have tried this solution. The javascript opens the target - but again in the same tab/window.Sulfuric
N
0

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

<form method="post" target="_blank">
...
</form>
Nitrate answered 5/12, 2020 at 21:17 Comment(0)
K
0

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

https://mcmap.net/q/421850/-open-link-in-new-tab-of-browser-from-pdf-file

Kinswoman answered 3/11, 2021 at 11:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.