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.
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');
});
You can also reproduce the problem in http://pdfkit.org/demo/browser.html with the code sample above.
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?
Most helpful comment
Is there any ETA for release? 馃巻