MCPcopy Create free account
hub / github.com/LibPDF-js/core / isPdfHeader

Function isPdfHeader

src/test-utils.ts:178–185  ·  view source on GitHub ↗
(bytes: Uint8Array)

Source from the content-addressed store, hash-verified

176 * @returns True if bytes start with "%PDF-"
177 */
178export function isPdfHeader(bytes: Uint8Array) {
179 // %PDF- = 0x25 0x50 0x44 0x46 0x2D
180
181 return (
182 // Fix: String.fromCharCode(...bytes) expects numbers, and map returns string[]
183 String.fromCharCode(...bytes.slice(0, 5)) === "%PDF-"
184 );
185}
186
187/**
188 * Find the PDF version from the header.

Callers 5

index.test.tsFile · 0.90
svg.test.tsFile · 0.90
drawing.test.tsFile · 0.90
getPdfVersionFunction · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected