blackbeam / poppler-simple

A simple javascript interface to poppler library
Apache License 2.0
37 stars 14 forks source link

Feature request: Add `getAnnots` to `NodePopplerPage` #28

Open itsachen opened 5 years ago

itsachen commented 5 years ago

Hi,

I'm trying to use poppler-simple to do some light PDF validation work. Specifically, I want to determine if a PDF contains annotations of a certain subtype.

I noticed that the library exposes some annotation methods/data but I'm looking for functionality similar to getAnnots exposed by poppler. It looks like that method returns a collection of Annots, each of which exposes some potentially useful information.

From a Node perspective, the method could return an array of objects:

import { PopperDocument } from 'poppler-simple';

const doc = new PopplerDocument(pathToSomeDocument);
const page = doc.getPage(pageNum);

const annots = page.getAnnots();
console.log(annots);
// [
//   {
//     ref: {
//       object: 270,
//       generation: 0
//     },
//     subtype: "Link"
//   },
//   {
//     ref: {
//       object: 210,
//       generation: 0
//     },
//     subtype: "FreeText"
//   },
// ]

Just curious what your thoughts were on this. If this sounds alright I could take a stab at this and put up a PR.

-Anthony