1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <?php
// Ouverture du rapport
$COM_Object="CrystalReports11.ObjectFactory.1";
$ObjectFactory= New COM($COM_Object);
//echo "<p>ObjectFactory bien crée.<p>About to create CrystalRunTime.Application...<p>";
try {
com_load_typelib('CrystalDesignRunTime.Application');
$app_obj = $ObjectFactory->CreateObject("CrystalRunTime.Application");
} catch (com_exception $e) {
echo("erreur lors de la création de l'instance :<br>".$e->getMessage());
exit;
}
$etat="E:/www/app/components/prestation/rpt/test.rpt"; // chemin du rapport
$rpt_obj=$app_obj->OpenReport($etat,1);
// Generer le fichier en pdf
$rpt_obj->ExportOptions->DiskFileName="E:/www/app/components/prestation/exports/prestation.pdf"; // chemin ou mettre le fichier pdf
$rpt_obj->ExportOptions->PDFExportAllPages=true;
$rpt_obj->ExportOptions->DestinationType=1; // Export to File
$rpt_obj->ExportOptions->FormatType=31; // Type: PDF
$rpt_obj->Export(false);
//libération
$rpt_obj = null;
$app_obj = null;
$ObjectFactory = null;
// ouverture du fichier pdf
$my_pdf="exports/prestation.pdf";
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="'.$my_pdf.'"');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Pragma: anytextexeptno-cache', true);
header('Cache-control: private');
header('Expires: 0');
header('Content-Disposition: inline; filename="'.$my_pdf.'"');
// readfile($my_pdf);
header('Location: '.$my_pdf);
?> |
Partager