cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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

0 Likes
View Entire Topic
Former Member
0 Likes

Will I need CR server ?

- No you will not

How do i actually invoke CR from PHP ?

- I have no idea. PHP is not a supported language, thus I have never even seen PHP. However, as you will be using COM, you will have to use the Report Designer Component (RDC) - more bellow.

The error:

Failed to create COM object `CrystalRuntime.Application'

and the code indicates that you are not instantiating the Application runtime object correctly.

E.g.; instead of:




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

try:

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


Now, the above assumes you are using CR XI R1 (11.0). It's usually a good idea to be exact in the version of CR used (See Help | About Crystal... in the CR designer).

Other RDC resources (all will be for VB6).

Sample apps

http://www.sdn.sap.com/irj/boc/businessobjects-samples

http://wiki.sdn.sap.com/wiki/display/BOBJ/ReportDesignerComponentSDKCOM+Samples

http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/00635998-751e-2b10-9cba-f50ee1e4ef81

Also, please note

1) CR XI R1 (11.0) is out of support, CR XI R2 (11.5) will be out of support end of this month.

2) CR XI R2 is the last version of CR to ship the RDC

3) I would highly recommend updating your install to CR XI R2A. See the blog [Where did all the Crystal Reports XI R1 and R2 fixes go?|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/24977] [original link is broken];

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]