Back to Jspdf

split_text_to_size

docs/module-split_text_to_size.html

4.2.12.3 KB
Original Source

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:
NameTypeDescription
textstring
optionsObject
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.4) to get 'mm' etc.

Parameters:
NameTypeDescription
textstring
optionsstring
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:
NameTypeDescription
textstring

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