Static Functions
16 Dec 202524 minutes to read
Root static functions of Pdf Component
_isGeneralCharacter
Determines if a given character code represents a general character in the ASCII range.
| Parameter | Type | Description |
|---|---|---|
| characterCode | number |
The character code to evaluate. |
Returns boolean
_isGraphicCharacter
Evaluates whether the provided character code corresponds to a graphic character
within the standard ASCII range.
| Parameter | Type | Description |
|---|---|---|
| characterCode | number |
The character code to evaluate. |
Returns boolean
_isPrintableCharacter
Checks if the provided character code corresponds to a printable character.
| Parameter | Type | Description |
|---|---|---|
| characterCode | number |
The character code to evaluate. |
Returns boolean
_validateDate
Validates the given date components to ensure they form a legitimate date.
| Parameter | Type | Description |
|---|---|---|
| dataType | string |
string - A descriptive label for the type of data being validated. |
| year | number |
The year part of the date, which must be a safe integer. |
| month | number |
The month part of the date, ranging from 0 (January) to 11 (December). |
| date | number |
The day part of the date, required to be a valid day in the given month. |
Returns void
_validateDateTime
Validates a full date and time specification to ensure it is legitimate.
| Parameter | Type | Description |
|---|---|---|
| dataType | string |
string - A descriptive label for the type of data being validated. |
| year | number |
number - The year component of the date. |
| month | number |
number - The month component of the date, 0-based (0 for January, 11 for December). |
| date | number |
number - The day of the month. |
| hours | number |
number - The hour component of the time. |
| minutes | number |
number - The minute component of the time. |
| seconds | number |
number - The second component of the time. |
Returns void
_validateDateTimeComponent
Creates a function to validate dateTime components.
| Parameter | Type | Description |
|---|---|---|
| unitName | string |
The name of the dateTime unit (e.g., ‘day’, ‘month’). |
| min | number |
The minimum allowable value for this unit. |
| max | number |
The maximum allowable value for this unit. |
Returns Object
_validateTime
Validates the given time components to ensure they form a legitimate time.
| Parameter | Type | Description |
|---|---|---|
| dataType | string |
A descriptive label for the type of data being validated. |
| hours | number |
The hour component of the time, which must be a safe integer from 0 to 23. |
| minutes | number |
The minute component of the time, which must be a safe integer from 0 to 59. |
| seconds | number |
The second component of the time, which must be a safe integer from 0 to 59. |
Returns void
isNumericString
Determines if the given character code corresponds to a numeric character
or a space character in the ASCII range.
| Parameter | Type | Description |
|---|---|---|
| characterCode | number |
number - The character code to evaluate. |
Returns boolean
_bufferToInteger
Convert a buffer to an integer.
| Parameter | Type | Description |
|---|---|---|
| input | Uint8Array |
The input buffer as a Uint8Array. |
Returns number
_convertBytesToText
Decodes a Uint8Array to a string using the specified text encoding.
Returns string
_decodeSignedBigEndianInteger
Decodes a signed big-endian integer from a Uint8Array.
| Parameter | Type | Description |
|---|---|---|
| value | Uint8Array |
The byte array representing the signed integer in big-endian format. |
Returns number
_decodeUnsignedBigEndianInteger
Decodes an unsigned big-endian integer from a Uint8Array.
| Parameter | Type | Description |
|---|---|---|
| value | Uint8Array |
The byte array representing the unsigned integer in big-endian format. |
Returns number
_dissectFloat
Dissects a floating-point number into its sign, exponent, and mantissa components.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The floating-point number to dissect. |
Returns Object
_encodeBigEndianSignedInteger
Encodes a signed 32-bit integer to a big-endian Uint8Array.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The signed integer to encode. Must be within the range -2147483648 to 2147483647. |
Returns Uint8Array
_encodeUnsignedBigEndianInteger
Encodes an unsigned 32-bit integer into a big-endian Uint8Array.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The unsigned integer to encode. Must be within the range 0 to 4294967295. |
Returns Uint8Array
_encodeX690BinaryRealNumber
Encodes a floating-point number into an X690 binary real number format (as a Uint8Array).
| Parameter | Type | Description |
|---|---|---|
| value | number |
The floating-point number to encode. |
Returns Uint8Array
_getBit
Retrieves the value of a specific bit from a Uint8Array.
| Parameter | Type | Description |
|---|---|---|
| from | Uint8Array |
The Uint8Array from which the bit value is extracted. |
| bitIndex | number |
The index of the bit to retrieve (0-indexed). |
Returns boolean
_integerToBuffer
Converts an integer into a buffer (Uint8Array) representation.
| Parameter | Type | Description |
|---|---|---|
| int | number |
The integer to convert to a Uint8Array. |
Returns Uint8Array
_isBasicEncodingElement
Checks whether a given Uint8Array is BER-encoded.
BER (Basic Encoding Rules) encoding for a sequence starts with the bytes 0x30 0x80
| Parameter | Type | Description |
|---|---|---|
| input | Uint8Array |
The input byte array to check. |
Returns boolean
_packBits
Packs a Uint8ClampedArray of bits into a Uint8Array of bytes.
| Parameter | Type | Description |
|---|---|---|
| bits | Uint8ClampedArray |
The array of bits to be packed. Each bit should be 0 or 1. |
Returns Uint8Array
_setBit
Sets or clears a bit at a specific index in a Uint8Array.
| Parameter | Type | Description |
|---|---|---|
| to | Uint8Array |
The Uint8Array into which the bit will be set or cleared. |
| bitIndex | number |
The index of the bit to set or clear, 0-indexed. |
| value | boolean |
A boolean indicating whether to set (true) or clear (false) the bit. |
Returns void
_setBitInBase256
Sets or clears a bit at a specific index in a Uint8Array for Base-256 encoding.
| Parameter | Type | Description |
|---|---|---|
| to | Uint8Array |
The Uint8Array into which the bit will be set or cleared. |
| bitIndex | number |
The index of the bit to set or clear, 0-indexed. |
| value | boolean |
A boolean indicating whether to set (true) or clear (false) the bit. |
Returns void
_appendChar
Convert character code to string.
| Parameter | Type | Description |
|---|---|---|
| value | number |
Input value. |
Returns string
_arabicToLetter
Convert arabic numbers to alphabet.
| Parameter | Type | Description |
|---|---|---|
| arabic | number |
Input value. |
Returns string
_arabicToRoman
Convert arabic numbers to roman style.
| Parameter | Type | Description |
|---|---|---|
| intArabic | number |
Input value. |
Returns string
_areUint8ArraysEqual
Compares two Uint8Array instances for byte-wise equality.
| Parameter | Type | Description |
|---|---|---|
| a | Uint8Array |
The first Uint8Array to compare. |
| b | Uint8Array |
The second Uint8Array to compare. |
Returns boolean
_bigIntToBytes
Converts a BigInt to a Uint8Array using big-endian byte order.
| Parameter | Type | Description |
|---|---|---|
| n | bigint |
The BigInt value to convert. |
Returns Uint8Array
_bytesToBigInt
Converts a Uint8Array to a BigInt by interpreting the bytes as a big-endian integer.
| Parameter | Type | Description |
|---|---|---|
| bytes | Uint8Array |
The byte array to convert. |
Returns bigint
_bytesToHex
Converts a Uint8Array to a hexadecimal string representation.
| Parameter | Type | Description |
|---|---|---|
| buffer | Uint8Array |
The input byte array to convert. |
Returns string
_checkInkPoints
Gets the boolean if two arrays are equal.
| Parameter | Type | Description |
|---|---|---|
| inkPointsCollection | Point[][] |
Ink points collection. |
| previousCollection | Point[][] |
Previous collection. |
Returns boolean
_checkRotation
Gets the page rotation.
| Parameter | Type | Description |
|---|---|---|
| page | PdfPage |
Page. |
| height | number |
Height. |
| left | number |
Left. |
Returns number
_checkType
Checks the type of the image using header bytes.
| Parameter | Type | Description |
|---|---|---|
| imageData | Uint8Array |
image data. |
| header | number[] |
header bytes. |
Returns boolean
_compressStream
Compresses the content of a PDFBaseStream
| Parameter | Type | Description |
|---|---|---|
| stream | _PdfBaseStream |
Base stream to compress. |
| isExport | boolean |
Denotes compress the stream as a hex-encoded string. |
Returns string
_convertDateToString
Converts a Date object to a string in the PDF date format ‘D:YYYYMMDDHHMMSSOHH’MM’SS’’.
| Parameter | Type | Description |
|---|---|---|
| dateTime | Date |
The Date object to be converted to a string. |
Returns string
_convertNumber
Convert number respect to ordered list number style.
| Parameter | Type | Description |
|---|---|---|
| intArabic | number |
Input value. |
| numberStyle | PdfNumberStyle |
Number style. |
Returns string
_convertStringToDate
Converts a PDF date string into a JavaScript Date object.
| Parameter | Type | Description |
|---|---|---|
| date | string |
The date string to convert. |
Returns Date
_convertToHex
Converts a single hexadecimal character to its numeric value.
| Parameter | Type | Description |
|---|---|---|
| char | string |
A single character string representing a hexadecimal digit (‘0’-‘9’, ‘A’-‘F’, ‘a’-‘f’). |
Returns number
_copyRange
Copy values from one array to another.
| Parameter | Type | Description |
|---|---|---|
| target | number[] |
destination array. |
| at | number |
target index. |
| source | number[] |
source array. |
| start | number |
start index. |
| end | number |
end index. |
Returns void
_createFontMetrics
Gets the form field font metrics.
| Parameter | Type | Description |
|---|---|---|
| fontDictionary | _PdfDictionary |
Form field. |
| height | number |
Font family. |
| baseFontName | string |
Font name. |
| font | PdfStandardFont |
The font. |
Returns _PdfFontMetrics
_createFontStream
Creates a font stream for the given font and form, extracting the font data from font descriptors.
| Parameter | Type | Description |
|---|---|---|
| form | PdfForm |
The target PDF form containing cross-references to the font data. |
| font | _PdfDictionary |
The dictionary that defines the font, containing references to font descriptors. |
Returns Uint8Array
_createRandomInRange
Generates a random BigInt within the inclusive range [min, max].
Uses rejection sampling to ensure uniform distribution.
Falls back to a smaller random if no valid candidate is found after 1000 attempts.
| Parameter | Type | Description |
|---|---|---|
| min | bigint |
The minimum value (inclusive). |
| max | bigint |
The maximum value (inclusive). |
Returns bigint
_decodeFontFamily
Decodes a font family string that contains hexadecimal encoded characters.
| Parameter | Type | Description |
|---|---|---|
| fontFamily | string |
The font family string to be decoded. May contain hex encoded characters prefixed by ‘#’. |
Returns string
_decodeText
Decode text.
| Parameter | Type | Description |
|---|---|---|
| text | string |
Text to decode. |
| isColorSpace | boolean |
Color space or not |
| isPassword | boolean |
Password or not |
Returns string
_defaultToString
Gets the default string.
| Parameter | Type | Description |
|---|---|---|
| item |
string | number | string[] | number[] | Object | Object[] | boolean
|
Input string. |
Returns string
_defineLazyProperty
Defines a non-enumerable property on an object.
Returns any
_defineProperty
Defines a property on an object with specific attributes.
Returns any
_extractAttributes
Extracts the attributes element from a DER-encoded ASN1 collection.
| Parameter | Type | Description |
|---|---|---|
| abstractSyntaxCollection | _PdfUniqueEncodingElement |
The ASN1 collection from which attributes are to be extracted. |
Returns _PdfUniqueEncodingElement
_getBigInt
Returns a function that converts a value to bigint.
Returns Object
_getCjkDescendantFont
Creates and returns a descendant CIDFont dictionary for a specified CJK font family.
| Parameter | Type | Description |
|---|---|---|
| family | PdfCjkFontFamily |
The CJK font family to be used. |
| style | PdfFontStyle |
The font style to apply. |
| metrics | _PdfFontMetrics |
The font metrics containing width table, PostScript name, and other font-specific data. |
Returns _PdfDictionary[]
_getCjkEncoding
Returns the appropriate CJK font encoding name based on the specified PdfCjkFontFamily.
| Parameter | Type | Description |
|---|---|---|
| fontFamily | PdfCjkFontFamily |
The cjk font family. |
Returns _PdfName
_getCjkSystemInfo
Returns the CIDSystemInfo dictionary for the specified CJK font family.
| Parameter | Type | Description |
|---|---|---|
| family | PdfCjkFontFamily |
The CJK font family for which the system information is needed. |
Returns _PdfDictionary
_getDecoder
Gets the image decoder.
| Parameter | Type | Description |
|---|---|---|
| imageData | Uint8Array |
image data. |
Returns _ImageDecoder
_getFontFamily
Gets the form field font family.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Font name. |
Returns PdfFontFamily
_getFontFromDescriptor
Gets the font data.
| Parameter | Type | Description |
|---|---|---|
| dictionary | _PdfDictionary |
font dictionary. |
Returns Uint8Array
_getFontSize
Gets the form field font size.
| Parameter | Type | Description |
|---|---|---|
| field | PdfField |
Form field. |
| family | PdfFontFamily |
Font family. |
Returns number
_getFontStyle
Gets the font style.
| Parameter | Type | Description |
|---|---|---|
| fontFamilyString | string |
Font family string. |
Returns PdfFontStyle
_getPageIndex
Gets the page index.
| Parameter | Type | Description |
|---|---|---|
| loadedDocument | PdfDocument |
Loaded document. |
| pageDictionary | _PdfDictionary |
Page dictionary. |
Returns number
_getSize
Number of bytes required to save the number.
| Parameter | Type | Description |
|---|---|---|
| input | number |
number. |
Returns number
_grayToRgba
Converts a grayScale image data array to an RGBA image data array.
| Parameter | Type | Description |
|---|---|---|
| src | Uint8Array |
The source grayScale data array. |
| dest | Uint32Array |
The destination RGBA data array. |
Returns void
_handleExplicitConversion
Handle explicit conversion
| Parameter | Type | Description |
|---|---|---|
| value | Uint8Array |
Input value. |
Returns Uint8Array
_hasUnicodeCharacters
Checks if the given string contains any Unicode (non-ASCII) characters.
| Parameter | Type | Description |
|---|---|---|
| value | string |
The string to check for Unicode characters. |
Returns boolean
_isLittleEndian
Checks if the current environment is little-endian.
Returns boolean
_isNullOrUndefined
Check whether the value is null or undefined.
| Parameter | Type | Description |
|---|---|---|
| value | any |
Input value. |
Returns boolean
_isRightToLeftCharacters
Check whether the input string contains any right-to-left (RTL) characters.
| Parameter | Type | Description |
|---|---|---|
| input | string |
The input string. |
Returns boolean
_isUnicode
Determines whether a given string contains Unicode characters.
| Parameter | Type | Description |
|---|---|---|
| value | string |
The string to be checked. |
Returns boolean
_log2
Calculates the base-2 logarithm of a number and rounds it up to the nearest integer.
| Parameter | Type | Description |
|---|---|---|
| x | number |
The number to calculate the logarithm for. |
Returns number
_mapFont
Map the font.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Font name. |
| size | number |
Font size. |
| style | PdfFontStyle |
Font style. |
| annotation |
PdfAnnotation | PdfField
|
Annotation or Field. |
| fontDictionary (optional) | _PdfDictionary |
Font dictionary. |
Returns PdfFont
_mapRubberStampIcon
Map rubber stamp icon.
| Parameter | Type | Description |
|---|---|---|
| iconString | string |
String value. |
Returns PdfRubberStampAnnotationIcon
_mathClamp
Clamps a number between a minimum and maximum value.
| Parameter | Type | Description |
|---|---|---|
| v | number |
The number to clamp. |
| min | number |
The minimum value. |
| max | number |
The maximum value. |
Returns number
_modInverse
Computes the modular inverse of a number a modulo m.
That is, finds x such that (a * x) % m === 1.
Uses the Extended Euclidean Algorithm.
| Parameter | Type | Description |
|---|---|---|
| a | bigint |
The number to find the inverse of. |
| m | bigint |
The modulus. |
Returns bigint
_modPow
Computes modular exponentiation: (base^exp) mod mod.
Efficiently calculates large powers using the right-to-left binary method.
| Parameter | Type | Description |
|---|---|---|
| base | bigint |
The base number. |
| exp | bigint |
The exponent. |
| mod | bigint |
The modulus. |
Returns bigint
_obtainFontDetails
Gets the form field font.
| Parameter | Type | Description |
|---|---|---|
| form | PdfForm |
form. |
| widget | PdfWidgetAnnotation |
widget annotation. |
| field (optional) | PdfField |
field. |
Returns PdfFont
_pad2
Pads a single-digit number with a leading zero to ensure two-digit formatting.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The number to pad. |
Returns string
_padStart
Pads the current string with another string (multiple times, if needed)
Returns string
_randomBigInt
Generates a cryptographically insecure random BigInt of the specified bit length.
The result is a non-negative BigInt with up to bitLength bits.
| Parameter | Type | Description |
|---|---|---|
| bitLength | number |
The desired bit length of the random number. |
Returns bigint
_readInteger8
Reads a signed 8-bit integer from the specified offset in the given data array.
| Parameter | Type | Description |
|---|---|---|
| data | Uint8Array |
The data array containing the bytes. |
| offset | number |
The position in the data array to start reading. |
Returns number
_readUnsignedInteger16
Reads a 16-bit unsigned integer from the specified offset in the given data array.
| Parameter | Type | Description |
|---|---|---|
| data | Uint8Array |
The data array containing the bytes. |
| offset | number |
The position in the data array to start reading. |
Returns number
_readUnsignedInteger32
Reads a 32-bit unsigned integer from the specified offset in the given data array.
| Parameter | Type | Description |
|---|---|---|
| data | Uint8Array |
The data array containing the bytes. |
| offset | number |
The position in the data array to start reading. |
Returns number
_resolveCjkFontFamily
Resolves and returns the corresponding PdfCjkFontFamily enum value based on the given PostScript font name.
| Parameter | Type | Description |
|---|---|---|
| postScriptName | string |
The PostScript name of the CJK font. |
Returns PdfCjkFontFamily
_resolveStandardFontFamily
Resolves and returns the corresponding PdfFontFamily enum value based on the given PostScript font name.
| Parameter | Type | Description |
|---|---|---|
| postScriptName | string |
The PostScript name of the font. |
Returns PdfFontFamily
_setRotateAngle
Sets the rotation angle for a PDF annotation if necessary.
It ensures that the rotation is within the normalized range [0, 360) degrees.
| Parameter | Type | Description |
|---|---|---|
| rotateAngle | number |
The rotation angle to be set for the annotation. Negative values are normalized. |
| annot | PdfAnnotation |
The PDF annotation object which may have its rotation angle modified. |
Returns void
_stringToBigEndianBytes
Convert the string to big endian bytes.
| Parameter | Type | Description |
|---|---|---|
| input | string |
string. |
Returns number[]
_toSigned16
Gets the signed 16 bit value.
| Parameter | Type | Description |
|---|---|---|
| value | number |
input value. |
Returns number
_toSigned32
Gets the signed 32 bit value.
| Parameter | Type | Description |
|---|---|---|
| value | number |
input value. |
Returns number
_toUnsigned
Gets the unsigned value.
| Parameter | Type | Description |
|---|---|---|
| value | number |
input value. |
| bits | number |
bits to process. |
Returns number
_tryParseFontStream
Gets the font stream.
| Parameter | Type | Description |
|---|---|---|
| crossReference | _PdfCrossReference |
Cross reference. |
| annotation |
PdfAnnotation | PdfField
|
Annotation. |
| fontResourceName (optional) | string |
Font resource name. |
Returns Uint8Array
_unreachable
Throws an error with the given message.
| Parameter | Type | Description |
|---|---|---|
| msg | string |
The error message. |
Returns void
_updateBounds
Update the annotation bounds.
| Parameter | Type | Description |
|---|---|---|
| annotation | PdfAnnotation |
annotation. |
| bounds (optional) | number[] |
annotation bounds. |
Returns number[]
_updatePageCount
Updates the page count value in the dictionary
| Parameter | Type | Description |
|---|---|---|
| dictionary | _PdfDictionary |
Dictionary to update page count. |
| valueToIncrement | number |
Page count. |
Returns void
_updatePageSettings
Updates the page settings in the dictionary
| Parameter | Type | Description |
|---|---|---|
| dictionary | _PdfDictionary |
Dictionary to update page settings. |
| settings | PdfPageSettings |
PDF page settings. |
Returns void