tags:

views:

20

answers:

1

How can I get a page count from a tiff file for faxes? using "g4" format. Language preferred is c++

A: 

Two options that come to mind.

  1. Have a look at LibTIFF. www.libtiff.org

This library is used by many other open source libraries and can be used for much more than just getting a page count from a Group4 Multi-page TIFF file. This is probably the easiest, quickest and cheapest approach. I noticed there is a section of code in tiff2pdf program that counts the tiff pages. You can probably adapt this code to suit your needs. There are versions suitable for Linux and Windows.

  1. Download the full TIFF specification at http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf and write your own code.

Basically a multipage tiff is a whole lot of singe page tiffs merged together. There are headers that include offsets to the next page. To get the pagecount you need to traverse the headers and keep count until you hit then end of the chain. The code should be quite simple once you have the correct header structures and use fread() and fseek() to traverse the chain.

Andrew Cash