- Add methods to measure width and height of text strings in both standard and embedded fonts.
- Allow use of the full range of UTF-8 and UTF-16 characters supported by embedded fonts.
- Allow use of ZapfDingbats and Symbol standard fonts with the proper encodings.
PDFDocument.embedFont
is now deprecated. Please usePDFDocument.embedNonstandardFont
instead.- When drawing text (with the
drawText()
ordrawLinesOfText()
operators, for example), please be sure to use thefont.encodeText()
method for the font you are using. This is highly recommended for both standard and nonstandard fonts (and is required if you want to use characters outside the ascii range). - The following examples demonstrate usage of the new
font.widthOfTextAtSize()
andfont.heightOfFontAtSize()
methods to measure text, as well as usage of thefont.encodeText()
method to encode characters outside the ascii range.- https://github.com/Hopding/pdf-lib#embed-font-and-measure-text
- https://github.com/Hopding/pdf-lib/tree/master/examples/measuring_text/node/
- https://github.com/Hopding/pdf-lib/blob/master/__integration_tests__/tests/test11.ts
- https://github.com/Hopding/pdf-lib/blob/master/__integration_tests__/tests/test12.ts