Hi, just wanna share to everyone after tried and tested many many times to create report in PDF format from Crystal Report.
Finally I can do it without any error.
Here is my system; PHP 5.1.6, MSSQL2005 and Crystal Report Server XI RL2
<?php
echo "Print Report Test";
$my_report = "D:\\Folder1\\SubFolder1\\Report.rpt"; rpt source file
$my_pdf = "D:\\Folder1\\SubFolder1\\Report.pdf"; $ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); $crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application"); $creport = $crapp->OpenReport($my_report, 1); $creport->Database->Tables(1)->SetLogOnInfo("servername", "DBname", "user", "password");
$creport->EnableParameterPrompting = 0;
$creport->DiscardSavedData;
$creport->ReadRecords();
$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;
print "<embed src=\"D:\\Folder1\\SubFolder1\\Report.pdf\" width=\"100%\" height=\"100%\">"
?>
That's all for me, anyway in Crystal Report I have to check DisCardSavedData, Save data with report and AutoSave (1 min) in Option Tab and also in Report Options I have to check save dat with report, too.
Hope this should be help to anybody
Casanoteva