Skip to content

Disable line break between two .text() calls #1655

@karimmakhloufi

Description

@karimmakhloufi

Question

I'm using pdfkit to generate text where syllables are differently colored.
I'm having an issue to avoid line breaks in the middle of a word because I call .text() each time I want to change color.
Is it possible to make that 2 calls are unbreakable ?

Code sample

You can test if you put this code in https://pdfkit.org/examples/browserify/browser.html

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

doc.fontSize(25)
  .text("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", {continued: true})
  .text("bb", {continued:true})
  .fillColor("red")
  .text("b", {continued: true}) 
doc.end();
stream.on('finish', function() {
  iframe.src = stream.toBlobURL('application/pdf');
});

As you can see, I need the multiple b to be one word but with different colors and it breaks

is there a way to avoid the break ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions