Pdfkit: Everything is link until continued = false

Created on 15 Oct 2019  路  8Comments  路  Source: foliojs/pdfkit

Bug Report

Description of the problem

Everything after the link is still treated as a link until continued: false.

In my example below only blue text should be clickable but also the green text is a link.

Code sample

var doc = new PDFDocument();
var stream = doc.pipe(blobStream());

doc.fillColor('red')
.text('Text text text ', {
  continued: true
})
.fillColor('blue')
.text('link', {
  link: 'http://www.example.com',
  continued: true
})
.fillColor('green')
.text(', text text text', {
  link: null
});

// end and display the document in the iframe to the right
doc.end();
stream.on('finish', function() {
  iframe.src = stream.toBlobURL('application/pdf');
});

Your environment

You can also reproduce the problem in http://pdfkit.org/demo/browser.html with the code sample above.

  • pdfkit version: 0.10.0
  • Node version: 12.7.0
  • Browser version: -
  • Operating System: Catalina

Most helpful comment

Is there any ETA for release? 馃巻

All 8 comments

This has been fixed in master but hasn't been released yet. see https://github.com/foliojs/pdfkit/blob/master/CHANGELOG.md

Is there any ETA for release? 馃巻

Is there any ETA for release?

I'm waiting for https://github.com/foliojs/pdfkit/pull/1030

In the mean time, you can try: https://www.npmjs.com/package/pdfkit-next

In the mean time, you can try: https://www.npmjs.com/package/pdfkit-next

The current release (0.10.0) doesn't seem to fix it :(
Does anybody have an expectation for a hot fix to be published?

@lsmenicucci please post a complete self contained example showing the error, since the provided code works with current release

Thanks for the quick reply!

I've used the PDFKit Browser Demo to reproduce the bug, but the same occurs with pdfkit 0.11.0 installed on Nodejs 12.0.0. Here's the code I've used on the live demo:

// create a document and pipe to a blob
var doc = new PDFDocument();
var stream = doc.pipe(blobStream());

doc.text('Should be a link', { link:"http://google.com/", continued:true, underline:true })
doc.text(' and should not be a link', { continued:false, underline:false })

// end and display the document in the iframe to the right
doc.end();
stream.on('finish', function() {
  iframe.src = stream.toBlobURL('application/pdf');
});

The blob generated on the iframe has both text segments as links.

doc.text(' and should not be a link', { continued:false, underline:false })

replace by

doc.text(' and should not be a link', { link: null, underline:false })

replace by

doc.text(' and should not be a link', { link: null, underline:false })

It doesn't change anything to me, does it change for you?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

balsamiqMichele picture balsamiqMichele  路  4Comments

vovkvlad picture vovkvlad  路  5Comments

raesche picture raesche  路  4Comments

tm2josep picture tm2josep  路  5Comments

durango picture durango  路  4Comments