Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using link option in doc.text, All non-link text becomes hyperlink to top of document. #991

robbinsa530 opened this issue Jun 21, 2019 · 1 comment


Copy link

commented Jun 21, 2019

Bug Report

When using link option in doc.text function, All non-link text becomes hyperlink to top of document.

Description of the problem

I had code which used pdfkit v0.9.0 that handled having inline links in a long document by using the link and continued options of the doc.text function. When adding links, it would set the link option to the address of the link, and when writing normal text, it would set the link option to 0. This was the only way to "turn off" the links when continued was set to true.

However, in v0.10.0 this method of "turning off" the links doesn't work, and anytime a piece of text is written with link set to 0, or if a piece of text is written at all in the same line as a link (e.g. when continued was previously set to true), it will become a hyperlink to the top of the document.

The below piece of code works as expected (only the link will be clickable) in v0.9.0, but in v0.10.0 all text will be clickable.

Code sample

const Document = require('pdfkit')
const fs = require('fs');

const doc = new Document();


string1 = "some long string that isnt a link ";
string2 = "this_is_a_link ";

  .text(string1, {
    underline: false,
    link: 0,
    continued: true ,

  .text(string2, {
    underline: true,
    link: "",
    continued: true,

  .text(string1, {
    underline: false,
    link: 0,
    continued: false,


Your environment

  • pdfkit version: 0.10.0
  • Node version: v10.15.2
  • Operating System: MacOS High Sierra 10.13.6

This comment has been minimized.

Copy link

commented Aug 27, 2019

I'm having this same issue.

The link is not used if it is null, but all null values are overwritten by the continued options, so there appears no way to turn off the link in the continued text. having a link of 0 is meant to go to the start of the document, so perhaps the link should not be rendered if it is false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.