Forum


Replies: 9   Views: 5039
Using conversion plugin to convert to pdf
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 jprateragg  · 15-08-2012 - 18:50

I'm using PHPDOCX v2.5 on Windows 2003. I've installed MS Office 2010 Professional Plus on the server. I'm trying to use transformDocxUsingMSWord() from your API guide ([url]http://www.phpdocx.com/documentation/api-documentation/transformdocxusingmsword-use-microsoft-word-for-format-conversion[/url]). After trying to convert a test document, I get this error:


Fatal error: Class 'COM' not found in C:\Inetpub\wwwroot\aganalysis\includes\phpdocx-pro-2.5\classes\MSWordInterface.inc on line 54

How can I fix this? Thanks!

Posted by admin  · 11-04-2013 - 12:13

Hello,

Please check this link:

http://php.net/manual/en/book.com.php

COM is a class for PHP that you should enable in your php config.

Regards.

Posted by jprateragg  · 11-04-2013 - 12:13

I made the necessary php.ini change and now I get this error:


Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': Access is denied. ' in C:\Inetpub\wwwroot\aganalysis\includes\phpdocx-pro-2.5\classes\MSWordInterface.inc:54 Stack trace: #0 C:\Inetpub\wwwroot\aganalysis\includes\phpdocx-pro-2.5\classes\MSWordInterface.inc(54): com->com('word.applicatio...') #1 C:\Inetpub\wwwroot\aganalysis\includes\phpdocx-pro-2.5\classes\CreateDocx.inc(4823): MSWordInterface->transformFormat('template_docx_t...', 'test.pdf') #2 C:\Inetpub\wwwroot\aganalysis\scrap2.php(24): CreateDocx->transformDocxUsingMSWord('template_docx_t...', 'test.pdf') #3 {main} thrown in C:\Inetpub\wwwroot\aganalysis\includes\phpdocx-pro-2.5\classes\MSWordInterface.inc on line 54

This looks like a permissions issue. But what permissions do I give which user, and and on what directory? Thanks!

Posted by jprateragg  · 11-04-2013 - 12:13

I made some DCOM changes to allow Everyone to use component services. I'm getting a new error now:


Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> This file could not be found. (C:WINDOWS...template_docx_text.docx)' in C:Inetpubwwwrootaganalysisincludesphpdocx-pro-2.5classesMSWordInterface.inc:60 Stack trace: #0 C:Inetpubwwwrootaganalysisincludesphpdocx-pro-2.5classesMSWordInterface.inc(60): variant->Open('template_docx_t...') #1 C:Inetpubwwwrootaganalysisincludesphpdocx-pro-2.5classesCreateDocx.inc(4823): MSWordInterface->transformFormat('template_docx_t...', 'test.pdf') #2 C:Inetpubwwwrootaganalysisscrap2.php(24): CreateDocx->transformDocxUsingMSWord('template_docx_t...', 'test.pdf') #3 {main} thrown in C:Inetpubwwwrootaganalysisincludesphpdocx-pro-2.5classesMSWordInterface.inc on line 60

I can't figure out why this is trying to access C:Windows..., but I can't see the entire directory b/c it puts the ... there. I tried looking specifically for a Word 2010 component, but it was not listed in DCOM Config. Do you have any proper setup instructions for using this on Windows and IIS?

EDIT: I ran this script:

<?php
$WrdApp = new COM("Word.Application");
if($WrdApp)
{
echo("Word.Application Connected.");
}
else
{
echo("Cannot Connect to Word.Application");
}
?>

And it successfully connected to Word.Application.

Posted by jprateragg  · 11-04-2013 - 12:13

Another update. I got it to work by using absolute paths:

$docx->transformDocxUsingMSWord('C:\Inetpub\wwwroot\app\template_docx_text.docx', 'C:\Inetpub\wwwroot\app\test.pdf');

Any reason why this doesn't work with relative paths?

Posted by paratus  · 15-04-2013 - 08:28

I have tried doing the same thing as you - I have windows server 2008 with Office 2010. I run my php file and the word docx is created. The instance of Word opens (i can see it in task manager) but the PDF never shows up. I have checked permissions, etc. but cannot work out why the PDF is not created.



Any ideas?


Posted by jorgelj  · 17-04-2013 - 09:06

Hello,



Can you run a simple example like?:



----------------------------------------



// starting word

$word = new COM("word.application") or die("Unable to instantiate Word");

echo 
"Loaded Word, version {$word->Version}\n";



//bring it to front

$word->Visible 1;



//open an empty document

$word->Documents->Add();



//do some weird stuff

$word->Selection->TypeText("This is a test...");

$word->Documents[1]->SaveAs("Useless test.doc");



//closing word

$word->Quit();



//free the object

$word null;



----------------------------------------



Regards.


Posted by jraa22  · 31-08-2013 - 23:17

Hi, I'm having the same problem. What DCOM Changes did you do? 


Posted by jorgelj  · 02-09-2013 - 09:00

Hello,



Please try the same example to check COM.



Regards.