Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Count the number of Pages in a Tiff or PDF file

Posted on 2014-11-12
6
Medium Priority
?
1,565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 51

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 55

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

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 55

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

722 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