split_text_to_size

jsPDF split_text_to_size plugin

Source:

Methods

(inner) getCharWidthsArray(text, options) → {Array}

Source:

Returns an array of length matching length of the 'word' string, with each cell occupied by the width of the char in that position.

Parameters:
Name Type Description
text string
options Object
Returns:
Type
Array

(inner) getStringUnitWidth(text, options) → {number}

Source:

Returns a widths of string in a given font, if the font size is set as 1 point.

In other words, this is "proportional" value. For 1 unit of font size, the length of the string will be that much.

Multiply by font size to get actual width in points Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc.

Parameters:
Name Type Description
text string
options string
Returns:

result

Type
number

(inner) splitTextToSize(text, size, options) → {Array}

Source:

Splits a given string into an array of strings. Uses 'size' value (in measurement units declared as default for the jsPDF instance) and the font's "widths" and "Kerning" tables, where available, to determine display length of a given string for a given font.

We use character's 100% of unit size (height) as width when Width table or other default width is not available.

Parameters:
Name Type Description
text string

Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string.

size number

Nominal number, measured in units default to this instance of jsPDF.

options Object

Optional flags needed for chopper to do the right thing.

Returns:

array Array with strings chopped to size.

Type
Array