vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
719 stars 178 forks source link

Adding findByteRange helper #99

Closed waaronking closed 4 years ago

waaronking commented 4 years ago

Per #98, this PR adds a findByteRange that properly parses the ByteRange field regardless of the spacing included inside. The function returns a byteRangeString and a byteRange array of values.

waaronking commented 4 years ago

Example of what findByteRange returns

const { findByteRange } = require('node-signpdf/dist/helpers');
console.log(findByteRange(pdfBuffer));
{
  byteRangeString: '/ByteRange [0 39317 44257 111062]',
  byteRange: [ '0', '39317', '44257', '111062' ]
}
{
  byteRangeString: '/ByteRange [ 0 /********** /********** /********** ]',
  byteRange: [ '0', '/**********', '/**********', '/**********' ]
}