pdf-signer-agetec
Version:
A JavaScript PDF signer with certificate A1 ICP-Brasil for NodeJS.
17 lines (16 loc) • 827 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const getPagesDictionaryRef = (info) => {
const isNotContainCatalogPositionWithSpace = info.root.toString().indexOf('/Type /Catalog') === -1;
const isNotContainCatalogPositionWithoutSpace = info.root.toString().indexOf('/Type/Catalog') === -1;
if (isNotContainCatalogPositionWithSpace && isNotContainCatalogPositionWithoutSpace) {
throw new Error('Failed to find the pages descriptor. This is probably a problem in node-signpdf.');
}
const pagesRefRegex = new RegExp('\\/Pages\\s+(\\d+\\s\\d+\\sR)', 'g');
const match = pagesRefRegex.exec(info.root);
if (match == null) {
throw new Error('Cant find a value for this regexp pattern.');
}
return match[1];
};
exports.default = getPagesDictionaryRef;