PHP Classes
elePHPant
Icontem

Convert Microsoft Word doc, docx to PDF: I want to convert doc file to a PDF file

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  All requests RSS feed  >  Convert Microsoft Word doc, docx to PDF  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

Convert Microsoft Word doc, docx to PDF

A request is featured when there is no good recommended package on the site when it is posted. Edit

Picture of Andsraj by Andsraj - 6 months ago (2015-08-08)

I want to convert doc file to a PDF file

This request is clear and relevant.
This request is not clear or is not relevant.

+3

Please suggest any solution to convert a Microsoft Word document file to a PDF file using a PHP script.

  • 2 Clarification requests
  • 6. Picture of Samuel Adeshina by Samuel Adeshina - 6 months ago (2015-08-10) Reply

    I agree with Manuel, using libreoffice also depends on what you need the solution for. If it's meant for the public, i don't think it's such a very good idea.

    • 1. Picture of Manuel Lemos by Manuel Lemos - 6 months ago (2015-08-09) Reply

      I don't think there is a solution to do that directly.

      What exists are some classes that generate PDF from HTML.

      Eventually it may be possible to convert Word documents to HTML or even save the Word documents as HTML.

      So you may combine the two solutions to achieve your final result. Would that work for you?

      • 2. Picture of Andsraj by Andsraj - 6 months ago (2015-08-09) in reply to comment 1 by Manuel Lemos Comment

        Thanks for your reply. Kindly suggest how can we convert doc file to html and It should be same format as in doc file like (bold, font style, etc.)

      • 3. Picture of Andsraj by Andsraj - 6 months ago (2015-08-09) in reply to comment 2 by Andsraj Comment

        I searched and found this is possible means doc to pdf using libreoffice. please give me the steps to convert it. It can be for windows and linux server also.

        Thanks in advance.

      • 4. Picture of Manuel Lemos by Manuel Lemos - 6 months ago (2015-08-09) in reply to comment 2 by Andsraj Comment

        There are classes to convert Microsoft Word to HTML but they use COM objects. That means that you need to be running PHP on Windows.

        An alternative solution would be to call some Web service API that actually perform that conversion. There are some that perform that service, but most that I see, they charge for the API access although some allow a free trial period.

        Another solution would be to parse the DOCX file which is basically a ZIP file with XML of the Word document inside and try to rebuild the document as far as possible.

        I don't know a class that does this but could be an innovative idea to solve the problem.

      • 5. Picture of Manuel Lemos by Manuel Lemos - 6 months ago (2015-08-09) in reply to comment 3 by Andsraj Comment

        I think it may be possible to convert files with libreoffice but you need to have it installed in the machine you are using.

        Usually that requires Linux X-Windows GUI (Gnome or KDE) installed. Do you think you can install that on your server?

      • 7. Picture of Axel Hahn by Axel Hahn - 6 months ago (2015-08-16) in reply to comment 5 by Manuel Lemos Comment

        Using libreoffice for converting does not need X environment. I use Libreoffice (requires java on your server too)

        /usr/bin/lowriter --headless --convert-to pdf [infile]

        This means: for each conversion it starts a new process. It is OK to convert a few docs. Otherwise search for a daemon mode of libreoffice.

        I wrote a PHP class to act as a spooler + converter to handle files, queuing and cleanup. But to convert a function with an exec is enough.

      • 8. Picture of Manuel Lemos by Manuel Lemos - 6 months ago (2015-08-16) in reply to comment 7 by Axel Hahn Comment

        You are right, when you use the --headless paramter, it does not require X-Windows.

        That spooler converter class is interesting. I am sure it would help many people that need to convert many documents. It would be great if you could submit it.

    Ask clarification

    Recommend package
    : 
    :