/    Sign up×
Community /Pin to ProfileBookmark

word doc to php

Is there any way to count the number of pages in a word document when it is uploaded using php?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Jun 16.2004 — That can be difficult since Word has single lines of code that can be well over 2500 characters. The closest way I know is to count lines and assume that 250 lines=1 page. I know it's not 100% accurate but I also know that a formatted text Word document of 5 pages comes out to 1253 lines when viewed in a text editor.
Copy linkTweet thisAlerts:
@redijediJun 16.2004 — I don't know if this is the best way, but it's certainly fun: Export the word file to XML before uploading. On upload use your XML parsing weapon of choice (DOM, SAX) to find the <o:Lines> node. This node contains the line numbers. There are also many other metadata available.

On second thought, forget the xml parsing and use a regex. That would be much simpler.

I never got it to work, and it more than likely will not work on *nix boxen, but php does have some com functionality if you wish to wrestle with that.
×

Success!

Help @daed17 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...