Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Count the number of Pages in a Tiff or PDF file

Posted on 2014-11-12
6
Medium Priority
?
1,668 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 52

Assisted Solution

by:Gustav Brock
Gustav Brock earned 1000 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 56

Accepted Solution

by:
Joe Winograd, EE MVE 2015&2016 earned 1000 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Six Sigma Control Plans
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

886 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