简体   繁体   English

在使用 pdfTron 创建的 PDF 文件的新选项卡中打开所有链接

[英]Open all links in a new tab in PDF file created with pdfTron

I want to open all links from my PDF file generated with pdfTron and react in a new browser window. If I open the document with a PDF viewer and click on a link, it works fine as the link opens in a new browser tab.我想打开使用 pdfTron 生成的pdfTron文件中的所有链接,并在新浏览器 window 中react 。如果我使用 PDF 查看器打开文档并单击链接,它会正常工作,因为链接会在新的浏览器选项卡中打开。 But if I initially open the PDF in the browser, when clicking on a link, the new page opens in the same tab and I need it to open on a new tab.但是,如果我最初在浏览器中打开 PDF,当单击链接时,新页面会在同一选项卡中打开,我需要它在新选项卡中打开。 Adding target="_blank" on the <a> didn't help although this is working on the HTML template which is generated before the PDF file is created.<a>上添加target="_blank"没有帮助,尽管这适用于在创建 PDF 文件之前生成的 HTML 模板。 Doing it from native JS (using window.open ) was also impossible.从原生 JS(使用window.open )做这件事也是不可能的。 Is there a way I can add an event listener maybe from pdfTron to tell all the links to open in a new tab?有没有办法可以从 pdfTron 添加一个事件侦听器来告诉所有链接在新选项卡中打开? Please advise, thanks!请指教,谢谢!

Unfortunately, you can't specify this in the PDF itself.不幸的是,您不能在 PDF 本身中指定它。 You can, however, try modifying your links to point to an intermediate page which opens the link in a new tab.但是,您可以尝试修改您的链接以指向在新选项卡中打开链接的中间页面。 PDFTron has a guide on how to do something like this here: PDFTron 在此处提供了有关如何执行此类操作的指南:

https://community.pdftron.com/t/how-do-i-open-a-pdf-link-a-url-hypelink-in-a-new-browser-window/172 https://community.pdftron.com/t/how-do-i-open-a-pdf-link-a-url-hypelink-in-a-new-browser-window/172

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM