Well I found on stackoverflow how to count pages of PDF file using Ghostscript by executing the following command on a shell
gs -q -dNODISPLAY -c "($PATH_TO_PDF) (r) file runpdfbegin pdfpagecount = quit"')
I would like to get the pdf from stdin.
I'll played a little bit around, but with no success.
My approach was:
gs -q -dNODISPLAY - -c "(%stdin) (r) file runpdfbegin pdfpagecount = quit"')
I get no output.
Any hints or suggestions?