1
votes

I'm having trouble getting started Crystal Reports XI with PHP 5 but I'm having trouble getting started.

Here's some code I used:

//rpt source file 
$my_pdf = "d:\\sauve\\report.pdf"; // RPT export to pdf file 
//-Create new COM object-depends on your Crystal Report version 
$ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // call COM port 
$crapp = $ObjectFactory-> CreateObject("CrystalRuntime.Application"); // create an instance for Crystal 
$creport = $crapp->OpenReport($my_report, 1); // call rpt report 

//- Set database logon info - must have 
$creport->Database->Tables(1)->SetLogOnInfo ("SUA_DB", "test.mdb", "", ""); 

//- field prompt or else report will hang - to get through 
$creport->EnableParameterPrompting = 0; 

//- DiscardSavedData - to refresh then read records 
$creport->DiscardSavedData; 
$creport->ReadRecords(); 


//export to PDF process 
$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf 
$creport->ExportOptions->PDFExportAllPages=true; 
$creport->ExportOptions->DestinationType=1; // export to file 
$creport->ExportOptions->FormatType=31; // PDF type 
$creport->Export(false); 

//------ Release the variables ------ 
$creport = null; 
$crapp = null; 
$ObjectFactory = null; 

//print "<embed src=\"D:\\pop\\EMMEC\\Etats\\RPT-list.pdf\" width=\"100%\" height=\"100%\">"
$file = 'E:/report.pdf';
$filename = 'report.pdf'; /* Note: Always use .pdf at the end. */

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);
?>

source link: http://php.net//manual/kr/class.com.php I got a message error: Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object CrystalRuntime.Application' in C:\wamp\www\classes\report\index.php on line 8 ( ! ) com_exception: Failed to create COM objectCrystalRuntime.Application': Classe non enregistrée in C:\wamp\www\classes\report\index.php on line 8

line8: $ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // call COM port

I've already installed CrystalRuntime 11.5 version Does anybody know what module I'm missing or if I'm doing something wrong in php? Do I need some library? Configure pnp.ini? Configure Crystal report? I've never worked with COM before.

I need help with the connection (step by step)!

1

1 Answers

0
votes

You need to add in your php.ini the following lines:

[COM_DOT_NET]
extension=php_com_dotnet.dll