Skip to content

splitTextToSize uses inverse scale factor #3230

@zornwal

Description

@zornwal

The documentation of splitTextToSize states it uses "measurement units declared as default for the jsPDF instance".
Thus when I define the constructor

let doc = new jsPDF('p', 'px', 'a4');

a line that spans the entire page should be 595.28pt * 96 / 72 = ~793.7 pixels wide.
One would then expect that

let splitText = doc.splitTextToSize(longText, 793.7);
doc.text(splitText, 0, 0)

produces lines that spans the entire page, but this not the case.

A page-spanning line is achieved at ~446 pixels like so

let splitText = doc.splitTextToSize(longText, 446);
doc.text(splitText, 0, 0)

Now, 446 happens to be 595.28 / (96 / 72), or 595.28 * (72/96), leading me to conclude that, somehow, an inverse scale factor is being applied between pt and px when adding text

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