ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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)
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.