Solved

Export .doc to .pdf in php

Posted on 2008-06-13
4
3,788 Views
Last Modified: 2008-11-21
I want to create .pdf files from .doc. I would like to use any php library for it and I would like to avoid any command-line solution.
0
Comment
Question by:SWB-Consulting
4 Comments
 
LVL 24

Accepted Solution

by:
purplepomegranite earned 250 total points
ID: 21783614
Funnily enough I have a requirement to do exactly the same thing.

However, I don't believe it is possible to achieve this directly from PHP.  Or rather, that anyone has implemented it - most document conversion to pdf is based on printer gdis, which means the converter doesn't actually have to understand the source file, just the printer data.  To convert .doc to .pdf solely using PHP you'd need to be able to read the Word document using PHP, and then output it (which is the easy bit).  It would be a huge task I think to write a PHP library that could decipher a Word document appropriately.

It would be easily possible via command-line.  Many utilities convert to pdf, as I'm sure you know.  The only issue there is having access to command-line tools on the server.  On my test server (which is mine), I do... on my production server (hosted), I don't... so I also can't implement a command-line solution.  Unfortunately I have had to use a workaround for the requirement due to lack of being able to find any native way of converting Word docs... I have required the user to convert his own documents using CutePDF.
0
 
LVL 3

Assisted Solution

by:Xorlev
Xorlev earned 250 total points
ID: 21783811
You can't convert .doc with pure PHP, but what I've done is used abiword (via command line) to convert documents to HTML. You can also have it convert to PDF, but for my use it was HTML.

If you want a pure PHP PDF solution, it's been done. It converts HTML -> PDF.
http://www.digitaljunkies.ca/dompdf/
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now