LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-18-2012, 02:24 PM   #1
ooolongT
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
How to find page count in a document


Does anyone know how to get a page count for docs other than PDFs? Like how about word docs?
 
Old 04-18-2012, 03:23 PM   #2
SrDorothy
LQ Newbie
 
Registered: Sep 2005
Location: Lacey, WA
Distribution: Mepis, Suse, Ubuntu
Posts: 22
Blog Entries: 15

Rep: Reputation: 6
Smile How to find page count in a .doc

Normally, if you have a .doc open in MS Word or another office application like LibreOffice, there is a status bar at the bottom of the window. At the left side in Libre is the page count, for example: Page 1 of 7 Can't recall if it is exactly the same in Word, but certainly somewhere on that status bar.
 
1 members found this post helpful.
Old 04-18-2012, 10:47 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
You want to do it programatically or interactively?
 
1 members found this post helpful.
Old 04-20-2012, 12:42 PM   #4
ooolongT
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Programatically

Wow, I also just realized how poorly stated my original question was, I apologize for the confusion.

With that said, thank you SrDorothy and catkin for your replies. I often deal with directories with hundreds or thousands of files in them of varied file types. Opening each one is not viable in my case, which is why I am wondering if there is something like xpdf or pdfinfo that works for text files, word files, and maybe, hopefully, spreadsheets.

So, what I want to be able to do is to run a script or series commands that will give the a total page count of all files in a directory, regardless of file type. That script would, therefore, probably include programs like xpdf or pdfinfo.


Thanks again!

Last edited by ooolongT; 04-20-2012 at 12:52 PM.
 
Old 04-20-2012, 12:51 PM   #5
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
actually you can change the number of pages by changing the font or margin, so I think you need to open the file and evaluate the content somehow. Maybe perl can help you, there are some modules to open documents and spreadsheets (either openoffice or MS office)
 
1 members found this post helpful.
Old 04-20-2012, 12:58 PM   #6
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,576

Rep: Reputation: 806Reputation: 806Reputation: 806Reputation: 806Reputation: 806Reputation: 806Reputation: 806
I doubt you can do it for spreadsheets since I don't think "page"means anything uuntil you come to print out and select print areas, and sometimes spreadsheets contain hidden cells or large areas of nothing. That and you could have any nmber of tabs.
 
1 members found this post helpful.
Old 04-20-2012, 02:07 PM   #7
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Use the command line interface for LibreOffice to accomplish this.

The brute force method is to use the example shown, exporting the document as PDF to a temporary file, then count the number of pages in it. It should work, but it does feel more than a bit clunky.

You might be able to write a macro that uses the print preview function to find out the number of pages, without generating any temporary files. Check out the documentation. You should be able to run that macro similar to the example, getting the page count directly.
 
1 members found this post helpful.
Old 04-20-2012, 05:40 PM   #8
ooolongT
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
pan64 & 273: I actually have a macro that formats .xls files for printing and gets rid of blank space, I think it leaves the fonts alone so maybe I just need to find a way to expand on that to output the page count once it has formatted it.


Nominal: I saw some documentation here that might help: http://ask.libreoffice.org/question/...om-the-command


But I haven't checked it out yet.
 
Old 04-20-2012, 10:58 PM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Maybe the best approach is to use each file type's associated program to print to file and then analyse that file for the page count.
 
Old 04-20-2012, 11:11 PM   #10
dugan
Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 5,002

Rep: Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560
Google: word vba page count.

Result:

Code:
Dim pageCount As Long
pageCount = docWord.ComputeStatistics(wdStatisticPages)
http://www.techtalkz.com/microsoft-o...tml#post360319

With the Word VBA macro language, you can do the rest (iteratively open each file in the directory, get their page counts, add it to the total) entirely from Word.

Last edited by dugan; 04-20-2012 at 11:16 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CUPS print quota by page count per user leonard.kroll Linux - General 0 05-12-2011 02:56 PM
Question about uploading a document into field web page - using google chrome joreg_ Linux - Software 0 11-23-2010 12:04 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 06:55 PM
how to find PDF page count mfoley Programming 8 02-26-2009 03:55 PM


All times are GMT -5. The time now is 03:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration