ncb000gt/node-gs — pull request #2 by ecarter (2012-12-03 17:34:07+00:00)
Title: support for page count and PostScript commands

Nice to access to page counts without the extra dependency of [Xpdf's](http://www.foolabs.com/xpdf/download.html) `pdfinfo(1)`.

:ghost: Ghostscript can do this with a little PostScript magic...

**Added support for page count:**

---

**#pagecount(callback...)** - get number of pages

```
gs()
.input('./test/pdfs/sizes.pdf')
.pagecount(function(err, count){
console.log('pages = ' + count);
});
```

_Which is basically just a shortcut for `#command()` and `#exec()` that sends the PostScript page count code to gs_

---

**#command(cmd)** - tells Ghostscript to interpret PostScript code using `-c "code"`

```
gs()
.q()
.input('./test/pdfs/sizes.pdf')
.command('(' + this._input + ') (r) file runpdfbegin pdfpagecount = quit')
.exec(function(err, data){
console.log('page count = ' + data);
});
```

---

Tests included :beers: