Link to home
Start Free TrialLog in
Avatar of anthonytr
anthonytrFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Count the number of Pages in a Tiff or PDF file

Is it possible to count the number of pages in a Tiff and/or PDF files in a dir?

I need to get the total pages from a collection of multipage tiff files or PDF files in a dir.

Thanks
SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of anthonytr

ASKER

I was hoping for something which could run from within my MS Access database and would be able to look at a Dir and calculate the page count all all tiff files in the Dir.

Perhaps i might have to rethink how i go about this.

Thanks for all your advice.
You're welcome. Sorry, I don't know enough about VBA in Access to help you with that approach. Regards, Joe
Hi, Thats ok.

I actually mis-read you answer.  I thought you were saying that what I was looking to do could NOT be done.  It's only when I re-read your answer that I realised you were actually saying the opposite.

I've been looking at the TiffTeller tool.  Using their command line tool, how would I call this from MS Access VBA?  They have the following example:

Usage: TiffTeller.exe <source> <destination> <options>
If you have path with spaces, use quotation marks.
 

Options:

-log <FileName> - Don`t show errors. Write them to the log file
-f - Export format
csv - Comma Separated Values, .csv (default)
dif - Data Interchange File Format, .dif
sylk - Symbolic Links Format, .slk
txt - Plain Text Format, .txt
-e - Show extensions
-r - Include suffolders
Note that -list is used when there is a list of files in a file.

Would it be possible to get the total page count back to my application?
> Would it be possible to get the total page count back to my application?

I haven't used the Tiff Teller command line call, but I have used both PDFtk and Xpdf's pdfinfo command line tools. All three of them work the same way — they put the information in a file. For example, PDFtk puts this line in a plain text file:

NumberOfPages: 3

Likewise, pdfinfo "prints" this line, among others (but it's easy to redirect to a plain text file):

Pages:          3

It seems that the Tiff Teller command line does something similar, even giving you a choice of output file format (csv, dif, sylk, txt), as well as providing an option for recursing into subfolders (-r). But at the end of the day, with all three of them, you'll need to read the files created and parse the output to extract the number of pages. I've done that many times with custom (stand-alone) programs, but I don't know to do it in VBA — I don't even know if it's possible to do in VBA. Regards, Joe