0
我的web應用程序通過TCPDF打開PDF文件,當用戶點擊一個按鈕:如何刪除臨時下載的文件?
function showOverviewThroughPdf(){
$oResp = $this->getResponse("tcpdf") ;
//NEW PDF DOCUMENT
$oResp->outputFileName = "liste_concepteur_matiere.pdf";
$oResp->doDownload = false;
$oResp->initPdf('L', 'mm', 'A4', null, null);
//settting
$oResp->tcpdf->SetFont ('pdfahelvetica', '', 12) ;
// set margins
$oResp->tcpdf->SetMargins(20, 20, 20) ;
$oResp->tcpdf->SetHeaderMargin(15) ;
$oResp->tcpdf->SetFooterMargin(15) ;
$oResp->tcpdf->SetAutoPageBreak(TRUE, 20) ;
// set image scale factor
$oResp->tcpdf->setImageScale(1.25);
$oResp->tcpdf->AddPage();
$iIdMatiere = $_SESSION["id_matiere"] ;
jClasses::inc ("sujet~questionSrv") ;
jClasses::inc ("commun~toolsSrv") ;
$oCurrentUser = jAuth::getUserSession() ;
$oCurrentUser = toolsSrv::getByCondition ("utilisateurs~users", "login", $oCurrentUser->login) ;
$oCurrentUser = $oCurrentUser [0] ;
$Questions = questionSrv::getAllQuestionsNotValidateByCondition ($iIdMatiere, null , $oCurrentUser->id, "id_question" , null,null, null) ;
$zHtml = "";
$i = 1 ;
foreach ($Questions["toQuestions"] as $tab){
if($tab->id_type_question == 2){
$zHtml .= "<dt> ". $i ." - " . questionSrv::text_to_texthtml($tab->lib_question) . " </dt>" ;
$zHtml .= "<dd> a) ". questionSrv::text_to_texthtml($tab->qcm_r1)."</dd>";
$zHtml .= "<dd> b) ". questionSrv::text_to_texthtml($tab->qcm_r2)."</dd>";
$zHtml .= "<dd> c) ". questionSrv::text_to_texthtml($tab->qcm_r3)."</dd>";
if(trim($tab->qcm_r4) !="")
$zHtml .= "<dd> d) ".questionSrv::text_to_texthtml($tab->qcm_r4)."</dd>";
if(trim($tab->qcm_r5) !="")
$zHtml .= "<dd> e) ".questionSrv::text_to_texthtml($tab->qcm_r5)."</dd>";
if(trim($tab->qcm_r6) !="")
$zHtml .= "<dd> f) ".questionSrv::text_to_texthtml($tab->qcm_r6)."</dd>" ;
} else {
$zHtml .= "<dt>". $i ." - " . questionSrv::text_to_texthtml($tab->lib_question) . "</dt>";
if($tab->epreuve_phase_sess != 1){
$zHtml .= "<dd> a) VRAI</dd>";
$zHtml .= "<dd> b) FAUX</dd>";
}
}
$i++;
}
$oResp->tcpdf->writeHTML($zHtml, true, 0, true, 0); // this opens the pdf thus creating a temporary file
return $oResp ;
}
在運行時出現在客戶端的計算機瀏覽器中創建的臨時文件。那麼如何在特定事件中刪除這個文件,例如,當用戶從我的應用程序斷開連接?
其中是$ pdf在我的代碼? – pheromix
我爲你編輯了答案 –