Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Front-end Validator


PDF Front Validator   |    Install   

PDF Front Validator

A lightweight TypeScript library for inspecting PDF file signatures in the browser and detecting files that were renamed with a .pdf extension.

Client-side file validation improves user feedback but does not replace server-side validation, malware scanning, or security controls.

Technology

  • ⚛️ React 18
  • ⛑ TypeScript
  • ⛑ Vite
  • 📏 ESLint
  • 💖 Prettier

Install

NPM:

npm i pdf-front-validator

Yarn

yarn add pdf-front-validator

Usage

React example

import { validateFilePDF } from 'pdf-front-validator'

function App() {
  const selectedFile = e.target.files[0]

    validateFilePDF(selectedFile)
    .then((result) => {
      if (result !== undefined) {
        // It's a PDF file
      } else {
        // It's not a PDF file
      }
    })
    .catch((error) => {
      console.error("Error to validate PDF File. ln: 58 Error => ", error);
      return;
    });
}

Made with 💗 by Patrick Gratão

About

A lightweight TypeScript library for validating PDF signatures in the browser and detecting files renamed with a .pdf extension.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages