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?
You cannot work with PDF files from stdin, as the PDF format makes it more or less essential to be able to have random access to all parts of the file.
In the cases where Ghostscript reads a PDF file from stdin it first copies it to a local file then works on that, so it isn't working from stdin anyway.
In short, this can't be done.
This works:
gs -q -dNODISPLAY -c "($PATH_TO_PDF) (r) file runpdfbegin pdfpagecount = quit";
I think the problem with your attempt to use
gs -q -dNODISPLAY -c "($PATH_TO_PDF) (r) file runpdfbegin pdfpagecount = quit"')
was the unmatched closing bracket after QUIT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With