Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
16 lines
511 B
Plaintext
16 lines
511 B
Plaintext
export function validatePDF(buffer) {
|
|
// Check for PDF header
|
|
const header = buffer.subarray(0, 8).toString('latin1');
|
|
if (!header.startsWith('%PDF-')) {
|
|
return false;
|
|
}
|
|
// Check for EOF marker and xref table
|
|
const endSize = Math.min(1024, buffer.length);
|
|
const end = buffer.subarray(buffer.length - endSize).toString('latin1');
|
|
if (!end.includes('%%EOF') || !end.includes('xref')) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//# sourceMappingURL=validatePDF.js.map |