parallax/jsPDF · error · Error
Invalid argument passed to jsPDF.getPageInfoByObjId
Error message
Invalid argument passed to jsPDF.getPageInfoByObjId
What it means
Thrown by jsPDF.getPageInfoByObjId when objId is NaN or not an integer. The guard `isNaN(objId) || objId % 1 !== 0` rejects non-numbers, fractional values, undefined, and strings that coerce to NaN. objId must be a valid PDF object id previously returned by getPageInfo().
Source
Thrown at src/jspdf.js:3330
var getPageInfo = (API.__private__.getPageInfo = API.getPageInfo = function(
pageNumberOneBased
) {
if (isNaN(pageNumberOneBased) || pageNumberOneBased % 1 !== 0) {
throw new Error("Invalid argument passed to jsPDF.getPageInfo");
}
var objId = pagesContext[pageNumberOneBased].objId;
return {
objId: objId,
pageNumber: pageNumberOneBased,
pageContext: pagesContext[pageNumberOneBased]
};
});
var getPageInfoByObjId = (API.__private__.getPageInfoByObjId = function(
objId
) {
if (isNaN(objId) || objId % 1 !== 0) {
throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");
}
for (var pageNumber in pagesContext) {
if (pagesContext[pageNumber].objId === objId) {
break;
}
}
return getPageInfo(pageNumber);
});
var getCurrentPageInfo = (API.__private__.getCurrentPageInfo = API.getCurrentPageInfo = function() {
return {
objId: pagesContext[currentPage].objId,
pageNumber: currentPage,
pageContext: pagesContext[currentPage]
};
});
/**View on GitHub (pinned to a3930ce03a)
Solutions
- Pass the numeric objId returned by getPageInfo().objId.
- Validate with Number.isInteger before calling.
- If you only have a page number, use getPageInfo(pageNumber) directly instead.
Example fix
// before
const info = doc.getPageInfoByObjId('5'); // string -> NaN
// after
const info = doc.getPageInfoByObjId(5); // numeric object id Defensive patterns
Strategy: validation
Validate before calling
function safeGetPageInfoByObjId(doc, objId) {
const id = Number(objId);
if (!Number.isInteger(id)) throw new Error('objId must be an integer');
return doc.getPageInfoByObjId(id);
} Type guard
function isIntegerId(v) { return Number.isInteger(v); } Prevention
- Use the numeric objId from getPageInfo().objId.
- If you only have a page number, call getPageInfo instead.
- Validate with Number.isInteger before calling.
When it happens
Trigger: Calling getPageInfoByObjId(undefined), with a fractional id, a string id like 'obj5', or an id that was never assigned. The function then iterates pagesContext looking for a matching objId.
Common situations: Passing an objId retrieved from the wrong structure; off-by issues where the caller assumes a string id; passing a page number instead of an object id.
Related errors
- Invalid argument passed to jsPDF.getPageInfo
- Invalid arguments passed to jsPDF.text
- Type of text must be string or Array. "{text}" is not recogn
- Unrecognized alignment option, use "left", "center", "right"
- Invalid arguments passed to jsPDF.line
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/c63b21758605da6c.
Report an issue: GitHub.