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.
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.
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.
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.
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.)
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.
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.
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 ).
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.
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.
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