pdftoimage
pdftoimage copied to clipboard
Error determining page count - fixable with change to grep command?
On rare occassions, I've encountered PDFToImage::PDFError: Error determining page count.
.
Working off of what's found on this line, https://github.com/robflynn/pdftoimage/blob/master/lib/pdftoimage.rb#L95, you can see for this particular document pdfinfo
does in fact return a page count:
pdfinfo /tmp/document.pdf
Title: Document
Author: https://imagemagick.org
Creator: https://imagemagick.org
Producer: https://imagemagick.org
CreationDate: Fri Sep 15 11:17:09 2023 PDT
ModDate: Fri Sep 15 11:17:09 2023 PDT
Custom Metadata: no
Metadata Stream: no
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 1
Encrypted: no
Page size: 611.242 x 791.252 pts (letter)
Page rot: 0
File size: 117406 bytes
Optimized: no
PDF version: 1.4
However, when we add | grep Pages
, it returns:
pdfinfo /tmp/document.pdf | grep Pages
Binary file (standard input) matches
It seems like changing grep Pages
to grep --text Pages
or grep -a Pages
fixes matters, but I'm not sure if there's a reason why that shouldn't be used by default.
For reference:
pdfinfo version 23.10.0
Copyright 2005-2023 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
I'm running on MacOS 14.0.
Thanks!