Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3811
  • Last Modified:

Export .doc to .pdf in php

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
SWB-Consulting
Asked:
SWB-Consulting
2 Solutions
 
purplepomegraniteCommented:
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
 
XorlevCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now