Solved

Export .doc to .pdf in php

Posted on 2008-06-13
4
3,793 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
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.

809 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