Solved

Count the number of Pages in a Tiff or PDF file

Posted on 2014-11-12
6
1,283 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 53

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 53

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 53

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

809 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