note 64022 added to class.com
| From: | djogopatrao at gmail dot com | Date: | Wed, 05 Apr 2006 19:25:00 +0000 |
| Subject: | note 64022 added to class.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107397@lists.php.net to get a copy of this message | ||
My previous notes about Crystal Reports have vanished away, but anyway I was up to correct them.
The code above connects to COM (beware of the version number! search on the Registry Editor for the
correct name to put in $COM_Object), opens a report from a file ($my_report), reload records from
database and then exports it to a PDF file ($my_pdf).
* IMPORTANT * this code, when invoked from the browser (I'm using Apache) AND with a report
that connects to a ODBC database, does not work (the problem is specificly the line ReadRecords(),
but may arise without it too when data is not saved into the report file).
But when you run this code by PHP-CLI (that is, by the command line), it works ok! I bug-reported
this, but have no answer till now ( give it a vote, if you thing it's important: http://bugs.php.net/bug.php?id=36959 ).
Also, exceptions may arise, so put it on a try_catch block.
--------------------------
// by dfcp '06 (djogopatrao@gmail.com)
$COM_Object = "CrystalReports11.ObjectFactory.1";
$my_report = "C:\\report.rpt";
$my_pdf = "C:\\report.pdf";
$ObjectFactory= New COM($COM_Object);
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
$creport = $crapp->OpenReport($my_report, 1);
$creport->ReadRecords(); // attention!
$creport->ExportOptions->DiskFileName=$my_pdf;
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // Export to File
$creport->ExportOptions->FormatType=31; // Type: PDF
$creport->Export(false);
----
Server IP: 66.163.161.117
Probable Submitter: 201.52.35.45
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/class.com.php
Edit -- http://master.php.net/note/edit/64022
Del: integrated -- http://master.php.net/note/delete/64022/integrated
Del: useless -- http://master.php.net/note/delete/64022/useless
Del: bad code -- http://master.php.net/note/delete/64022/bad+code
Del: spam -- http://master.php.net/note/delete/64022/spam
Del: non-english -- http://master.php.net/note/delete/64022/non-english
Del: in docs -- http://master.php.net/note/delete/64022/in+docs
Del: other reasons-- http://master.php.net/note/delete/64022
Reject -- http://master.php.net/note/reject/64022
Search -- http://master.php.net/manage/user-notes.php