Solved

Count the number of Pages in a Tiff or PDF file

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

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 52

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 52

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

914 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

18 Experts available now in Live!

Get 1:1 Help Now