Members
(inner) allowFsRead
- Source:
Properties:
| Type | Description |
|---|---|
| Array.<string> | undefined |
Controls which local files may be read by jsPDF when running under Node.js.
Security recommendation:
- We strongly recommend using Node's permission flags (
node --permission --allow-fs-read=...) instead of this property, especially in production. The Node flags are enforced by the runtime and provide stronger guarantees.
Behavior:
- When present, jsPDF will allow reading only if the requested, resolved absolute path matches any entry in this array.
- Each entry can be either:
- An absolute or relative file path for an exact match, or
- A prefix ending with a single wildcard
*to allow all paths starting with that prefix.
- Examples of allowed patterns:
"./fonts/MyFont.ttf"(exact match by resolved path)"/abs/path/to/file.txt"(exact absolute path)"./assets/*"(any file whose resolved path starts with the resolved./assets/directory)
Notes:
- If Node's permission API is available (
process.permission), it is checked first. If it denies access, reading will fail regardless ofallowFsRead. - If neither
process.permissionnorallowFsReadis set, reading from the local file system is disabled and an error is thrown.
Example:
const doc = jsPDF();
doc.allowFsRead = ["./fonts/*", "./images/logo.png"]; // allow everything under ./fonts and a single file
const ttf = doc.loadFile("./fonts/MyFont.ttf", true);
Methods
(inner) loadFile(url, sync, callback) → {string|undefined}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | |
sync |
boolean | |
callback |
function |
Returns:
result
- Type
- string | undefined
(inner) loadImageFile(path, sync, callback)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | |
sync |
boolean | |
callback |
function |