LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 01: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, 02:23 PM   #2
SrDorothy
LQ Newbie
 
Registered: Sep 2005
Location: Lacey, WA
Distribution: Mepis (in the past), Suse, Ubuntu, LinuxMint
Posts: 24
Blog Entries: 15

Rep: Reputation: 7
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, 09:47 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You want to do it programatically or interactively?
 
1 members found this post helpful.
Old 04-20-2012, 11:42 AM   #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 11:52 AM.
 
Old 04-20-2012, 11:51 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
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, 11:58 AM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
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, 01:07 PM   #7
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
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, 04: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, 09:58 PM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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, 10:11 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
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 10:16 PM.
 
  


Reply



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 01:56 PM
Question about uploading a document into field web page - using google chrome joreg_ Linux - Software 0 11-22-2010 11:04 PM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
how to find PDF page count mfoley Programming 8 02-26-2009 02:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:09 PM.

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
Open Source Consulting | Domain Registration