Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Page count for PDF & TIFF files

Status
Not open for further replies.

randymce

IS-IT--Management
Oct 1, 2003
26
0
0
US
I need to be able to reliably count the number of pages in multi-page PDF and TIFF files. What seemed like a trivial task is turning into something much more difficult. I saw a thread from a couple years ago here - but I need something for handling very large PDF files that can run all day long without restarting.

For the time being, I'm using a solution from that same thread - running pdfinfo.exe > result.txt and parsing the resulting text file in my VFP app. I don't like this solution, and am thinking maybe an ActiveX control or something might be better!?

One key issue is that this is a network app with multiple PC clients - and I can't install a COM DLL on each PC. Nor can I purchase Acrobat for each PC.
 
don't know if this will work on larger PDf. i tested it quickly, and it seems to be working on pdf with 10 pages (i don't have a larger one)

lcStr = filetostr(getfile('pdf'))

lnPOS = At("/Count",lcStr)
If lnPOS > 0
lcPageCount = alltrim(substr(lcStr, lnPOS, 9))
lnPageCount = VAL(STRTRAN(lcPageCount,'/Count',''))
?lnPageCount
EndIf



Ali Koumaiha
TeknoSoft Inc.
Michigan
 
Thanks Ali. My mistake - I should have included the link to the earlier thread


Using filetostr() was an option in that thread as well.

Unfortunately, I'm using huge CAD files that are as big as 36"x48" and can contain dozens of pages.

In addition, after testing this earlier - I've found that the '/Count' doesn't always exist in some PDF's (due to creator? I'm not sure.)
 
I'm truly shocked at how difficult this task has become. I would never have imagined this information would be so difficult to extract - at least reliably. In any case, it appears running 'pdfinfo.exe' and parsing the results is as good as it gets for now. (Oddly, the only other thing that has worked consistently is actually extracting all the pages of the PDF file to a temporary folder, then counting the number of files... which is obviously even more tedious.)

Thanks everyone for at least looking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top