无法通过 rails 应用程序上的 pdfkit 在 PDF 上生成 _blank 链接
Can not generate _blank links on PDF via pdfkit on rails app
我有一个 rails 应用程序可以为给定的 html 部分生成 pdf。在部分中,我有许多目标为 _blank 的链接,但在生成的 PDF 中,目标看起来像是被忽略了。
我只想让 pdf 在新 tab/window 中打开链接。
PDFKIT 的合作者说
"This sounds like a problem with wkhtmltopdf (which is what renders the pdf from the html). (Pdfkit just wires up everything between ruby/rails and that binary.)"
如有任何帮助,我们将不胜感激。
此致,
Sean Hubers答案:
PDFs are not marked up with HTML. How a link click is handled in a PDF
depends on the PDF viewer you are using. Modern browsers with built-in
PDF viewers may navigate to the page within the same frame as the PDF
view and that is not something that can be controlled with an HTML
element attribute. What happens if your link is clicked when the PDF
is being viewed in Adobe Acrobat or Mac Preview? You're at the whim of
the software and operating system. Sorry to bear the bad news but this
is the reality of the PDF format.
我有一个 rails 应用程序可以为给定的 html 部分生成 pdf。在部分中,我有许多目标为 _blank 的链接,但在生成的 PDF 中,目标看起来像是被忽略了。
我只想让 pdf 在新 tab/window 中打开链接。
PDFKIT 的合作者说
"This sounds like a problem with wkhtmltopdf (which is what renders the pdf from the html). (Pdfkit just wires up everything between ruby/rails and that binary.)"
如有任何帮助,我们将不胜感激。
此致,
Sean Hubers答案:
PDFs are not marked up with HTML. How a link click is handled in a PDF depends on the PDF viewer you are using. Modern browsers with built-in PDF viewers may navigate to the page within the same frame as the PDF view and that is not something that can be controlled with an HTML element attribute. What happens if your link is clicked when the PDF is being viewed in Adobe Acrobat or Mac Preview? You're at the whim of the software and operating system. Sorry to bear the bad news but this is the reality of the PDF format.