Needlessly Provoking Marsupials

npm

Need private packages and team management tools?Check out npm Orgs. »

wcag-pdf

4.0.0 • Public • Published

Build Status js-standard-style

node-wcag-pdf

Check the Accessibility of a PDF Document using eiii.

You can check a pdf by url or path to file.

Installation

From npm

$ npm install wcag-pdf

From GiHub

$ git clone git@github.com:zrrrzzt/node-wcag-pdf.git

cd into directory and run the setup script

$ npm run setup

Usage

Supports promises and callbacks.

Promises

To check a pdf by url

'use strict'
 
const checkPdf = require('wcag-pdf')
const fileUrl = 'http://www.difi.no/sites/difino/files/difi-rapport-2015-7-digitale-barrierar-norske-nettstader.pdf'
 
checkPdf(fileUrl)
  .then(console.log)
  .catch(console.error)

returns

{ pdfIsValid: true,
  passed: 0,
  failed: 0,
  totalChecked: 0,
  resultUrl: '' }

if the pdf is not valid the result might look like this

{ pdfIsValid: false,
  passed: 4,
  failed: 4,
  totalChecked: 8,
  resultUrl: 'http://checkers.eiii.eu/en/pdfcheck/?url=https%3A//helsedirektoratet.no/Documents/Folkehelsearbeid%2520i%2520kommunen/Nyhetsbrev-folkehelsearbeid-2015-4.pdf' }

check a pdf by file

'use strict'
 
const checkPdf = require('node-wcag-pdf')
const filePath = 'test/data/invalid.pdf'
 
checkPdf(fileUrl)
  .then(console.log)
  .catch(console.error)

returns

{ pdfIsValid: false,
  passed: 4,
  failed: 4,
  totalChecked: 8,
  resultUrl: '' }

Callbacks

To check a pdf by url

'use strict'
 
const checkPdf = require('wcag-pdf')
const fileUrl = 'http://www.difi.no/sites/difino/files/difi-rapport-2015-7-digitale-barrierar-norske-nettstader.pdf'
 
checkPdf(fileUrl, (error, data) => {
  if (error) {
    console.error(error)
  } else {
    console.log(data)
  }
})

returns

{ pdfIsValid: true,
  passed: 0,
  failed: 0,
  totalChecked: 0,
  resultUrl: '' }

if the pdf is not valid the result might look like this

{ pdfIsValid: false,
  passed: 4,
  failed: 4,
  totalChecked: 8,
  resultUrl: 'http://checkers.eiii.eu/en/pdfcheck/?url=https%3A//helsedirektoratet.no/Documents/Folkehelsearbeid%2520i%2520kommunen/Nyhetsbrev-folkehelsearbeid-2015-4.pdf' }

check a pdf by file

'use strict'
 
const checkPdf = require('node-wcag-pdf')
const filePath = 'test/data/invalid.pdf'
 
checkPdf(filePath, function (error, data) {
  if (error) {
    console.error(error)
  } else {
    console.log(data)
  }
})

returns

{ pdfIsValid: false,
  passed: 4,
  failed: 4,
  totalChecked: 8,
  resultUrl: '' }

License

MIT

install

npm i wcag-pdf

Downloadsweekly downloads

18

version

4.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability