Skip to content

"Trying to access beyond buffer length" Error when trying to create with specific font #353

@Vikeo

Description

@Vikeo

Trying to use the font Arimo but I get this error.

Here's a reproduction repo: https://github.com/Vikeo/pdfmake-buffer-error

Stacktrace:

(node:68737) UnhandledPromiseRejectionWarning: RangeError: Trying to access beyond buffer length
    at checkOffset (repo/node_modules/pdfmake/build/pdfmake.js:2513:36)
    at Uint8Array.readInt16BE (repo/node_modules/pdfmake/build/pdfmake.js:2631:18)
    at DecodeStream.<computed> [as readInt16BE] (repo/node_modules/pdfmake/build/pdfmake.js:500:33)
    at NumberT.decode (repo/node_modules/pdfmake/build/pdfmake.js:807:36)
    at Struct._parseFields (repo/node_modules/pdfmake/build/pdfmake.js:1260:20)
    at Struct.decode (repo/node_modules/pdfmake/build/pdfmake.js:1226:10)
    at TTFGlyph._getCBox (repo/node_modules/pdfmake/build/pdfmake.js:65155:28)
    at TTFGlyph._getMetrics (repo/node_modules/pdfmake/build/pdfmake.js:65352:21)
    at TTFGlyph.get (repo/node_modules/pdfmake/build/pdfmake.js:65067:19)
    at TTFGlyph.descriptor.get (repo/node_modules/pdfmake/build/pdfmake.js:55707:23)
    at repo/node_modules/pdfmake/build/pdfmake.js:64544:38
    at Array.map (<anonymous>)
    at LayoutEngine.position (repo/node_modules/pdfmake/build/pdfmake.js:64543:42)
    at LayoutEngine.layout (repo/node_modules/pdfmake/build/pdfmake.js:64527:10)
    at TTFFont.layout (repo/node_modules/pdfmake/build/pdfmake.js:67129:31)
    at EmbeddedFont.layoutRun (repo/node_modules/pdfmake/build/pdfmake.js:70941:25)
    at EmbeddedFont.layoutCached (repo/node_modules/pdfmake/build/pdfmake.js:70961:20)
    at EmbeddedFont.layout (repo/node_modules/pdfmake/build/pdfmake.js:70981:24)
    at EmbeddedFont.widthOfString (repo/node_modules/pdfmake/build/pdfmake.js:71017:22)
    at widthOfString (repo/node_modules/pdfmake/build/pdfmake.js:55447:14)
    at repo/node_modules/pdfmake/build/pdfmake.js:55405:16
    at Array.forEach (<anonymous>)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:68737) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:68737) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

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