parallax/jsPDF

Support hyperlinks in html()

Open

#3,146 创建于 2021年4月21日

在 GitHub 查看
 (10 评论) (3 反应) (0 负责人)JavaScript (4,596 fork)batch import
Feature Requestdifficulty:hardhelp wanted

仓库指标

Star
 (28,280 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

I'm running jsPDF 2.3.1 to render PDFs from HTML. I am able to generate PDF files, but hyperlinks are not always rendering correctly.

Here are two examples:

<a href="https://github.com">https://github.com</a>

<a href="https://github.com">GitHub</a>

The first example generates a clickable link in the PDF (good), while the second example just colors the text blue with no hyperlinking (bad).

Here's the code I'm using to generate this:

const doc = new jsPDF('portrait', 'pt', 'letter');
const fullDocBody = '<a href="https://github.com">GitHub</a>'; 
doc.html(fullDocBody, {
  // Callback function is called when html conversion to PDF completes
  callback: function (doc) {
    doc.save('test.pdf');   // Saves to a file
  },
  x: 60,
  y: 60
 });

Changing fullDocBody to one of the two link strings shown above will demonstrate the behavior I am describing.

My application needs to accept either link type, as it is taking HTML from a rich text editor component to render the PDF.

Thanks for your time.

贡献者指南