Replies: 1   Views: 587
Docx->pdf conversion using ms word conversion plugin
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by daveiroquois  · 03-03-2022 - 15:01

We are trying to convert a Docx to PDF. Per your site's instructions, we installed Word on the server. We then ran this code:

$docx = new TransformDocAdvMSWord();
$docx->transformDocument("../../../resources/templates/GoodEnough1.docx", "../../../resources/templates/GoodEnough1.pdf");

And we get this error:

Fatal error: Uncaught com_exception: Failed to create COM object `word.application': Access is denied. in D:\Websites\Folder\ServiceRequestsAdmin\classes\phpdocx\v12.5\classes\TransformDocAdvMSWord.php:105 

We've also given all the proper access rights per the instructions listed on your website:

MS Word common problems and issues
  • Error using the active document: if the transformation returns an error related to unable to open the DOCX, the msword method allows to choose documents or active as selected content. The default value is active, if it fails documents must be chosen.
  • dcom config should be configured to allow "interactive user", "remote access" and "remote action", as well as adding the "IUSR" account.
  • Source and target files must use absolute paths and double backslashes: 'C:\\folder\\source.docx' .


Please advise, thank you.

Posted by admin  · 03-03-2022 - 17:42


The Access is denied error is a generic PHP COM error that appears when PHP COM can't access DCOM due to user missing permissions.

First we recommend testing the script using PHP CLI mode. Please note that to use the conversion plugin based on MS Word, absolute paths and double backslashes must always be used. For example, this is correct (from the example FormatConversion/transformDocument/msword/sample_1.php included in the package):

$docx->transformDocument('C:\\path\\transformDocument_msword_1.docx', 'C:\\path\\transformDocument_msword_1.pdf');

but the following line is not valid because it uses relative paths and single backslashes:

$docx->transformDocument('..\..\transformDocument_msword_1.docx', '..\transformDocument_msword_1.pdf');

After running this script using PHP CLI mode, please test the same using the web browser, checking that the user that is doing the conversion has the correct permissions. The generic steps to setup the correct permissions are the following:

1. In the command line put DCOMCNFG
2. Expand Console Root > Component Service > Computers, right-click on My Computer, And Select Properties
3. In the Tab COM Security > Launch and Activation Permissions Click in Edit Default
4. Add the User (Ex. IIS_IUSRS) or service
5. Check Allow Local Launch and Local Activation