creating a .pdf from .doc

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

creating a .pdf from .doc

Post by lc »

Ok did a heap of searches everywhere (here also) and I couldn't find anything that really helped me.

The situation is the following... A customer wants to upload a .doc file and automaticly send it as a .pdf file as a mail attachment.

Now creating a .pdf isn't really the issue, nor is sending as an attachment.

The .doc to .pdf conversion is troubling though.

The only option I could find was using a COM class to open Open Office to do the conversion, but that's no option on this server... sadly.

Has anyone got any ideas or pointers??? I'd really appreciate the help! ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you can't use OpenOffice, then you may need to use an online service or just have them upload PDF files. The latter is likely best due to them verifying the file is converted correctly (by use of a printer driver in Word itself.)
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

Well yeah... that'd be nice... but if that was an option I would have just done that in stead of spending hours looking for another solution.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You mean you can't just tell your users to send you a nicer file format?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

The "easiest" would be to install a pdf printer.. Then open the .doc with ms-word and print witht he pdf printer... Done ;)
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

Nah I can't have the customer do too much in this case... as usual they're quite technologicly challenged and having them create their own pdf file is really no option.

Installing a pdf printer would be lovely... but of course that is not an option either.... no access to the server, no way to have them do it for me.

Naturally everything is becoming more simple by the minute.

I'm afraid I'll probably end up having them enter the text in chunks in textareas and then creating the pdf on the fly from that... which is no problem, but it would create issues with layout and the ammount of chunks would have to be variable.... all in all quite a headache for both user and me.... I'm just hoping someone has a better idea.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

All they have to do is..

1. Open the document
2. Click File
3. Click Print
4. Select the PDF printer
5. Save the File
6. Upload it

If they can't do that, and they are willing to pay for a "more advanced" solution then hey, more money for you.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Even simpler, ask the ISP to install that driver.. If not, get one that does.

(Client is king.. Even when he's a programmer that needs to get a job done. When the hosting is provided by your clients, make them aware of the addiontal cost because their ISP doesn't cooperate.. In my experience they seem to have more influence on those ISPs ;))
ntbd
Forum Newbie
Posts: 21
Joined: Wed Apr 12, 2006 6:42 am

Post by ntbd »

Different idea... Try and play with Tiny MCE. This is a richtext editor script in Javascript, but it has an option to paste from word where it then converts all the formating to HTML, which you can then use to generate the PDF. Google Tiny MCE and look at their examples.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Just text or images too? If there's images in the documents (which come in various formats pre/post 95) then it's gonna be almost a no-goer. If its just text you might stand a chance... I think I've seen a class (not free) somewhere that can open MS Word documents without COM. I'll have another search.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

These days word has a 'xml' format.. Documentation can be found on microsoft/msdn.. But you still have to have to translate the xml to pdf..
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

You could have the clients save as RTF rather than DOC. As I recall RTF is pretty easy to parse and there are parsers available.
(#10850)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Most of the RTF parsers out there, however, are poorly written, and plus, with almost anything from Word (or anything WYSIWYG), you have to parse what they mean not what they wrote.
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

Well indeed... a word format would be an option, but not quite fool proof.

I think I can draw the conclusion that an online set of textareas combined with a table in the database is the way to go here.
I can't really see any other option that gives enough control. I've seen too many "customers" mess up o so simple tasks.
Post Reply