Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open link in new tab from PDF file

Tags:

I have created the PDF file programmatically. For this, I have used the HTML to PDF converting library. In my PDF there are some links for some pages of website.

I have implemented the html by following way and then converted it to PDF programmatically.

<a target="_blank" href="http://mywebsite_url_here.html">Link</a> 

But when opening this PDF into chrome or firefox browser and clicking on the any link exist in PDF. Links are opening is same TAB instead of the new TAB. Please help to find out the solution for this. so that my PDF reside in one tab and link will open in another tab in browser.

I have already tried

target="_blank"  target="_top"  <a onclick="window.open ('http://mywebsite_url_here.html', '');   return false" href="javascript:void(0);"></a> 

But nothing has worked for me.

like image 700
Rakesh Soni Avatar asked Sep 29 '16 06:09

Rakesh Soni


People also ask

Can you make PDF links open in a new tab?

Long answer: Hyperlinks in a PDF are different from Hyperlinks in HTML. PDF was not designed to be viewed as part of a browsing experience. Hence there is no option available for PDF Hyperlinks to open them in a new tab, because PDF does not know about the concept of tabs.

How do you open a link in a PDF in a new window?

On a PC, Control-Click on a hyperlink to open linked PDF in a new window. On a Mac, Option-Command-Click on a hyperlink to open linked PDF in a new window.

How do I get PDFs to open in separate tabs?

Go to preferences (Edit>Preferences - on Windows), or faster is control-K (cmd-K on Mac). Select the General category on the left, and look for the setting labelled 'Open documents as new tabs in the same window', and UNCHECK this. You will need to restart Acrobat for this to take effect.

How do I get a PDF to open in a new tab without downloading?

At the top right, click More Settings. At the bottom, click Show advanced settings. Under “Privacy”, click Content settings. Under “PDF Documents," check the box next to "Open PDF files in the default PDF viewer application.” (Uncheck this box if you want PDFs to open automatically when you click them.)

Is it possible to open a link in a PDF?

But when opening this PDF into chrome or firefox browser and clicking on the any link exist in PDF. Links are opening is same TAB instead of the new TAB. Please help to find out the solution for this. so that my PDF reside in one tab and link will open in another tab in browser.

How to open PDF in New Tab in Chromium Edge browser?

If we open a pdf file in chromium edge browser and click any link within the pdf, the link will open in same window or tab by default. Currently with Edge Chromium browser, we get option to right click the link in pdf and open it in new tab or window.

How do I edit a link in a PDF file?

Double-click the link rectangle. In the Actions tab of the Link Properties dialog box, select the listed action you want to change, and click Edit. Select the Add or Edit link tool ( Tools > Edit PDF > Link > Add or Edit ).

How do I open a PDF file in Internet Explorer?

Open Internet Explorer. Select Tools > Internet Options. Click the Programs tab. Click the Manage Add-ons button. Set the Show menu to "Add-ons that have been used by Internet Explorer." Find and select Adobe PDF Reader. Find and select Adobe PDF Reader and click OK.


Video Answer


1 Answers

Short answer: It is not possible in a cross-plattform, guaranteed-to-work way.

Long answer: Hyperlinks in a PDF are different from Hyperlinks in HTML. PDF was not designed to be viewed as part of a browsing experience. Hence there is no option available for PDF Hyperlinks to open them in a new tab, because PDF does not know about the concept of tabs.

There is some discussion in Adobe's forums about it, which boils down to „not directly possible, but you could embed JavaScript in the PDF to do it“. They give an EPS file as example:

%!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 100 100 %%EndProlog  [ /Rect [ 0 0 100 100 ] /Action << /Subtype /JavaScript /JS (app.launchURL\("PLACE-YOUR-URL-HERE", true\);) >> /Subtype /Link  /ANN pdfmark  %%EOF 

Now before you try and get this EPS file embedded in your PDF, be aware that Chrome's PDF viewer has very little support for embedded JavaScript, so it is not guaranteed to work. It may also issue a warning to the User that there is JavaScript code going to be executed if they click on it. I would say it isn't worth the hassle.

like image 97
flyx Avatar answered Oct 09 '22 16:10

flyx