cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Crystal Report with PHP

Former Member
0 Likes
8,154

Hi, I am new to crystal report. I want to use CR 11 integrated with my web based application. Now as entire application is designed in PHP, I need to use PHP, use COM, to pass parameters and generate PDF report.

I have following question.

Will I need CR server ?

How do i actually invoke CR from PHP ?

Right now I am doing following

$my_report = "C:
Inetpub
wwwroot
test
test.rpt";

$my_pdf = "C:\Inetpub\wwwroot\test
MyReport.pdf";

try

{

$ObjectFactory = new COM ( 'CrystalRuntime.Application' );

}

catch ( exception $e )

{

echo 'caught exception: ' . $e->getMessage () . ', error trace: ' . $e->getTraceAsString ();

}

$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");

$creport = $crapp->OpenReport($my_report, 1);

$creport->Database->Tables(1)->SetLogOnInfo("server IP address", "db_name", "username", "password");

$creport->EnableParameterPrompting = 0;

$creport->DiscardSavedData;

$creport->ReadRecords();

$creport->FormulaFields->Item(1)->Text = ("'My Report Title'");

$creport->ParameterFields(1)->AddCurrentValue ("FirstParameter");

$creport->ParameterFields(2)->AddCurrentValue (2000);

$creport->ExportOptions->DiskFileName=$my_pdf;

$creport->ExportOptions->PDFExportAllPages=true;

$creport->ExportOptions->DestinationType=1;

$creport->ExportOptions->FormatType=31;

$creport->Export(false);

$creport = null;

$crapp = null;

$ObjectFactory = null;

but i am getting following error

caught exception: Failed to create COM object `CrystalRuntime.Application': Invalid syntax , error trace: #0 C:\Inetpub\wwwroot\cr_test.php(69): com->com('CrystalRuntime....') #1 Notice: Undefined variable: ObjectFactory in C:\Inetpub\wwwroot\cr_test.php on line 78 Fatal error: Call to a member function CreateObject() on a non-object in C:\Inetpub\wwwroot\cr_test.php on line 78

I will appreciate any help provided in this matter

View Entire Topic
Former Member
0 Likes

Thank you.

I have gone through the document.

Looks like classic ASP is not one of the supported languages, am I correct on this one ?

Former Member
0 Likes

Classic ASP is supported - with the RDC SDK. Lots of info on ASP - type ASP Crystal in the search box at the top right corner of this web page.

- Ludek