Convert Word documents to php using COM (windows + apache)
Good day Habr! I want to talk a little bit about what needs to be done when using a COM object to convert word files to any of the available formats . I myself faced a lot of problems, I had a lot of forums, there are practically no Russian manuals. I decided to write, more for myself, but suddenly someone else will come in handy? If you have IIS, there is a possibility that you will not need it, the article is exclusively about setting up work under Apache
The first and main problem that caused brain rupture: Call to undefined method variant::SaveAs() when trying to save a document. Experiments often led to errors in the absence of a property in an object or document parsing errors, the most common Fatal error: Uncaught exception 'com_exception' with message ' Source: Unknown<br/> Description: Unknown'
What you need to do to ensure that the process still earned:
Need server screw
MsOffice package installed on it (or not the whole package, but only the necessary parts of it)
Setting permissions for COM
Next, go to Start-> Administrative Tools-> Component Services
Expand the menu Component Services-> Computers-> My Computer-> DCOM Config
In the list we are looking for the COM applications we need (as a rule, they all begin with the words Microsoft ...)
Click the right button for the item of interest, select Properties, go to the Securety tab in the Access Permissions section, put a dot in Customize and click on the Edit button
In the window that appears, click add and add a user who has rights to start apache (enter the user’s login in the bottom field and click Check Names if everything is fine, then Windows will find it, click ok)
In the list, select the added user and tick him Remote Acceess
Confirm all changes (click ok 2 times)
Repeat steps 4-7 for desired applications.
Apache setup
After the rights to COM are distributed all in the same window (Component Services) go to the Services section we find there apache click on it right click select Properties go to the Log On tab click on the Browse button enter the same user specified above for COM Objects, click OK, enter the password for the user account so that apache can start. Click OK.
Restart apache, if everything is correct, then restart will be successful