nordin
nordin

Reputation: 167

Class php_com_dotnet is missing in php

So I am using the call php_com_dotnet in my code:

$word = new COM("word.application");

// Hide MS Word application window
$word->Visible = 0;

//Create new document
$word->Documents->Add();

// Define page margins
$word->Selection->PageSetup->LeftMargin = '2';
$word->Selection->PageSetup->RightMargin = '2';

// Define font settings
$word->Selection->Font->Name = 'Arial';
$word->Selection->Font->Size = 10;

// Add text
$word->Selection->TypeText("TEXT!");

// Save document
$filename = tempnam(sys_get_temp_dir(), "word");
$word->Documents[1]->SaveAs($filename);

// Close and quit
$word->quit();
unset($word);

header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");

// Send file to browser
readfile($filename);
unlink($filename);

and I got his error:

Fatal error: Uncaught Error: Class 'COM' not found in /var/www/clients/client1/web1/web/nordin/save.php:6 Stack trace: #0 {main} thrown in /var/www/clients/client1/web1/web/nordin/save.php on line 6

so I looked around I added this to my php.ini file:

 [COM_DOT_NET]
 ;extension=php_com_dotnet.dll

 enable_dl = On
 ; extension_dir = "ext"

and it still doesn't work, what am I doing wrong? please help!

EDIT

my files are on a sftp server and I get error's like this:

 ini_set('display_errors', 1);
 ini_set('display_startup_errors', 1);
 error_reporting(E_ALL);

Upvotes: 0

Views: 2881

Answers (2)

Michael Niño
Michael Niño

Reputation: 467

The configuration is:

extension=com_dotnet

Upvotes: 1

John Conde
John Conde

Reputation: 219834

The semi-colon before the extension is a comment and means that extension is not enabled. To enable it you must remove that semi-colon:

;extension=php_com_dotnet.dll

becomes

extension=php_com_dotnet.dll

You may need to restart IIS after making this change.

Upvotes: 1

Related Questions