Skip to content

PdfErrorCode

PdfErrorCode = "INVALID_INPUT" | "FILE_NOT_FOUND" | "INVALID_PDF" | "PASSWORD_REQUIRED" | "INVALID_PASSWORD" | "INVALID_PAGE_NUMBER" | "RENDER_FAILED" | "DOCUMENT_CLOSED" | "MISSING_FONT" | "MISSING_GLYPHS" | "UNKNOWN"

Defined in: packages/core/src/types.ts:474

Error codes for PDF operations.

Each code identifies a specific type of error:

CodeDescription
INVALID_INPUTInput is not a valid file path, Buffer, Uint8Array, or ArrayBuffer
FILE_NOT_FOUNDThe specified file path does not exist
INVALID_PDFThe input data is not a valid PDF file
PASSWORD_REQUIREDThe PDF is encrypted and requires a password
INVALID_PASSWORDThe provided password is incorrect
INVALID_PAGE_NUMBERThe page number is out of range (less than 1 or greater than pageCount)
RENDER_FAILEDFailed to render a page to an image
DOCUMENT_CLOSEDAttempted to use a document after it was closed
MISSING_FONTFont is not embedded and cannot be rendered correctly
UNKNOWNAn unexpected error occurred

Example

import { PdfError, type PdfErrorCode } from 'noto-pdf-ts'
function handleError(code: PdfErrorCode): string {
switch (code) {
case 'PASSWORD_REQUIRED':
return 'Please provide a password'
case 'INVALID_PASSWORD':
return 'Wrong password'
case 'FILE_NOT_FOUND':
return 'File not found'
default:
return 'An error occurred'
}
}