UNPKG

payload

Version:

Node, React, Headless CMS and Application Framework built on Next.js

16 lines (15 loc) 511 B
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