Solved

Count the number of Pages in a Tiff or PDF file

Posted on 2014-11-12
6
1,116 Views
Last Modified: 2014-11-12
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
0
Comment
Question by:anthonytr
  • 3
  • 2
6 Comments
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 40438676
You will need a control that can read the files and extract the properties, like csXImage:

http://www.chestysoft.com/ximage/default.asp

A demo Access application is to download.

/gustav
0
 
LVL 51

Accepted Solution

by:
Joe Winograd, EE MVE earned 250 total points
ID: 40438739
I assume from your Topics of Miscellaneous Programming and VB Script that you want an API or command line interface that you can call from a program. One possibility is Tiff Teller, which supports both PDF and TIFF:
http://www.coolutils.com/tiffteller

I haven't used its command line interface, but you should be able to call it from VB Script or from any programming/scripting language that supports a command line call:
http://www.coolutils.com/CommandLine/TiffTeller

It's not free, but is reasonably priced:
http://www.coolutils.com/TiffTellerLicenses.php

I know of two free command line utilities that can return the count of pages in a PDF, but not one that can do it for a TIFF.

Update: I just discovered that the command line call of the excellent (and free!) IrfanView can return the count of pages in TIFF files (and in PDF files with its PlugIns installed). Btw, the two command line utilities mentioned above that can handle PDFs are PDFtk Server (<pdftk.exe>) and the PDFinfo tool (<pdfinfo.exe>) of the Xpdf library:

http://www.pdflabs.com/tools/pdftk-server/
http://www.foolabs.com/xpdf/

But the "free" aspect depends on how you use them — check their licensing.

With all of these utilities, it wouldn't be difficult to loop through a folder in VB Script (or any scripting language) to add up the page count for all files. For example, here's an article discussing an app that uses a different scripting language (but, of course, could be done in VB Script) to loop through all PDFs in a folder — and it uses PDFtk to extract the page count from the "dump_data":
http://www.experts-exchange.com/Web_Development/Document_Imaging/A_11211-How-To-Split-Rename-Move-a-Batch-of-PDF-Files-Based-on-Contents-of-the-Files.html

Regards, Joe
0
 

Author Comment

by:anthonytr
ID: 40438863
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 40438891
You're welcome. Sorry, I don't know enough about VBA in Access to help you with that approach. Regards, Joe
0
 

Author Comment

by:anthonytr
ID: 40438910
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?
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 40439052
> 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
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now