2013-11-13 3 views
-1

아래 codeigniter 코드에서 pdf 파일을 만들고 싶지만 webpage.And를 표시하고 자습서를로드합니다.이 사이트에서 http://blog.luutaa.com/php/generating-a-pdf-using-codeigniter/을 작성하고 도우미를 작성하고 mpdf 폴더를 작성하고 압축을 풉니 다. 파일을 PDF 파일에 넣고 pdf 용 contoller 코드를 넣으십시오. 그러나 문제는 해결되지 않습니다.Codeigniter PDF가 작동하지 않습니다

컨트롤러 :

<?php 

class Help extends ci_controller 
{ 
    function index() 
    { 

     $this->load->view('help_view'); 
    } 
    //to create the data and insetin to the coursesubject table 

    public function pdf_report(){ 
$this->load->helper(array('My_Pdf')); // Load helper 
$data = file_get_contents(site_url('http://localhost/seatingreport4/index.php/help')); // Pass the url of html report 
create_pdf($data); //Create pdf 
} 
} 
?> 

보기 :

<!DOCTYPE html> 
<html> 
<head> 
<?php include_once('header2.php'); ?> 
<div id="showhide"> 
<?php include_once('menu.php'); ?> 
</div> 
<a id="toggle" onClick="showorhide('showhide')"><img src="<?php echo base_url('img/m.jpg'); ?>" HEIGHT="40" WIDTH="40" BORDER="0" alt="logo"style="margin-bottom:7px; margin-top:7px;" /></a></a> 

<br> 
<div class="gray_bg"> 
     <div class="container"> 
      <div class="row welcome_inner"> 
       <div class="span13"> 
        <h1 class="p"><span class="k">///</span> Help</h1> 
       </div> 
      </div> 
     </div> 
    </div> 
<style> 
.k{ 
color:#339900; 
font-size: xx-large; 
} 
.p{ 

font-size: xx-large; 
font-weight:900; 
} 
</style> 
    <script src="//cdn2.editmysite.com/js/vendor/modernizr.js"></script> 
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,300,400,700" /> 



     <link rel="stylesheet" type="text/css" href="http://cdn2.editmysite.com/css/public.css?buildTime=1383786711" /> 

     <!--[if IE 8]><link rel="stylesheet" type="text/css" href="http://cdn2.editmysite.com/css/public-ie8.css?buildTime=1383786711" /><![endif]--> 
     <!--[if IE 7]><link rel="stylesheet" type="text/css" href="http://cdn2.editmysite.com/css/public-ie7.css?buildTime=1383786711" /><![endif]--> 


    <script> var loginData = {"use_ssl":true,"redirect":false}; var errorMsgs = {"wrongUserPass":"Wrong username or password","loginToAccess":"Please log-in to access that page","loginAgain":"Please log-in again to continue.","accountDeleted":"Your account was previously deleted","accountExists":"You already have an account. Please log-in.","loginInstead":"You already have an account. Please log-in."}; var DISABLE_SIGNUP_CAPTCHA = true; var facebook = {"app_id":"190291501407","domain":"www.weebly.com","user":false}; </script> 


     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 

     <script type="text/javascript" src="//cdn1.editmysite.com/libraries/prototype/1.7-custom/prototype.min.js?2"></script> 

     <script type="text/javascript" src="http://cdn2.editmysite.com/js/public/main.js?buildTime=1383786711"></script> 

</head> 


<body class="w-ui homepage"> 


<form id="weebly-signup"> 
    <div class="caret"></div> 

    <div id="signup-inputs"> 





     <div 

      id="weebly-email" 
      class="large block" 

      placeholder="Email" 
     /> 

     <div 

      id="weebly-new-password" 
      class="large block" 

      placeholder="Password" 
     /> 
    </div> 


    <div class="submit-btns"> 


    </div> 

    <input type="hidden" name="response" id="weebly-login-signup-response" /> 
    <input type="hidden" name="weebly-campaign" id="weebly-campaign" value="" /> 

</form> 


    </div> <!-- #sidebar-inner --> 
</div> <!-- #sidebar --> 


<div id="login-box" class="form-popover-box titled-box"> 
    <form id="weebly-login" method="post" action="https://www.weebly.com/weebly/login.php"> 
     <div class="caret"></div> 





     <input 
      type="text" 
      id="weebly-username" 
      class="large block" 
      name="user" 
      placeholder="Email or Username" 
      value="" 
     /><br> 

     <input 
      type="password" 
      id="weebly-password" 
      class="large block" 
      name="pass" 
      placeholder="Password" 
     /><br> 

     <p class="remember-me"> 
      <label> 
       <input 
        type="checkbox" 
        id="weebly-remember" 
        name="rememberme" 
        checked 
       /> 

      </label> 
     </p> 





    </form> 
</div>  






    <div id="how-it-works" class="section"> 
     <div class="hgroup"> 
      <h2>  Tips to work on Seating Application</h2> 

     </div> 



     <div class="article"> 
      <ol id="how-it-works-list"> 
       <li class="tips top"> 
        <div class="content"><span class="icon"></span></div> 
       </li> 
       <li> 
        <h4>  Master</h4> 
        <div class="content"> 
         <span class="talkbubble"><span class="icon grow"></span></span> 
         <span class="circle mask"><span class="icon grow" ></span></span> 
         <ul class="bubble"> 
          <li> Exam name,month and year is created in exam master </li> 
          <li>  Course code and name is created in course master</li> 
          <li>  Subject code and name is created in subject master</li> 
          <li>  Room details such room name,no of benches,maximum bench capacity,available status and invigilator is created in room master</li> 
         </ul> 

        </div> 

        <br><br><br><br> <br><br><br><br><br><br><br> 
       </li> 

       <li> 
        <h4>  Details</h4> 
        <div class="content"> 
         <span class="talkbubble"><span class="icon create"></span></span> 
         <span class="circle mask"><span class="icon create"></span></span> 

         <ul class="bubble"> 
          <li>  Course code and Subject code is created in course subject</li> 
          <li>  Exam name and course code is created in exam course</li> 
          <li>  Register no,name, course code and Subject code for a particular exam is created </li> 
          <li>   Update the course code ,subject code,date and session for particular exam </li> 
         </ul> 
        </div> 
        <br><br><br><br> <br><br><br><br><br> 
       </li> 
       <li> 
        <h4>  Seating Plan </h4> 
        <div class="content"> 
         <span class="talkbubble"><span class="icon publish"></span></span> 
         <span class="circle mask"><span class="icon publish"></span></span> 
         <ul class="bubble"> 
          <li>  Exam name is selected </li> 
          <li>  Date and session is selected </li> 
          <li>  Course code,Subject code and number of student id displayed </li> 
          <li>  Clicking on System generated it displays seat no ,register no and subject code</li> 
         </ul> 
        </div> 
        <br><br><br><br> <br><br><br> 
       </li> 
       <li> 
        <h4>  Seating Report </h4> 
        <div class="content"> 
         <span class="talkbubble"><span class="icon grow"></span></span> 
         <span class="circle mask"><span class="icon grow"></span></span> 
         <ul class="bubble"> 
          <li>  Exam name is selected </li> 
          <li>  Date and session is selected </li> 
          <li>  Course code,Subject code and number of student id displayed </li> 
          <li>  Selecting on the Subject code it display Room no,seat no,register no and invigilator as report </li> 
          <li>  Clicking on seating summary it displays exam name ,date,session,room no,subject code,register no ,no of students and invigilator</li>  
         </ul> 
        </div> 
        <br><br><br><br> <br><br><br><br><br> 
       </li> 
       <li> 
        <h4>  Upload</h4> 
        <div class="content"> 
         <span class="talkbubble"><span class="icon grow"></span></span> 
         <span class="circle mask"><span class="icon grow"></span></span> 
         <ul class="bubble"> 
          <li>  Exam name is selected </li> 
          <li>  Course code for relevant exam is selected </li> 
          <li>  Subject code for corresponding course code is selected </li> 
          <li>  Choose the csv file which has register no and students name and upload it </li>  
         </ul> 
        </div> 
        <br><br><br><br> <br><br><br><br><br> 
       </li> 
       <li class="tips bottom"> 
        <div class="content"><span class="icon"></span></div> 
       </li> 
      </ol> 
     </div> 
    </div> 
    <script> 
function showorhide(id){ 
    if(document.getElementById(id)){ //check the element exists and can be accessed 
     var ele = document.getElementById(id); //get hold of the element 
     if(ele.style.display=="none"){ //see if display property is set to none 
      ele.style.display="block";  
     }else{ 
      ele.style.display="none";  
     } 
    } 
} 
</script> 

<script> 
$('#showhide').hide(); 
</script> 
<style> 
.talkbubble { 
    width: 120px; 
    height: 80px; 
    background:#339900; 
    position: relative; 
    -moz-border-radius: 10px; 
    -webkit-border-radius: 10px; 
    border-radius:   10px; 
} 
.talkbubble:before { 


    position: absolute; 
    right: 100%; 
    top: 26px; 
    width: 0; 

    height: 0; 
    border-top: 13px solid transparent; 
    border-right: 26px solid red; 
    border-bottom: 13px solid transparent; 
} 
span.picture1 { 
    width:100px; /*width of your image*/ 
    height:100px; /*height of your image*/ 
    background-image:url('C:\wamp\www\seatingreport1\img\refresh.jpg'); 
    margin:0; /* If you want no margin */ 
    padding:0; /*if your want to padding */ 
} 
</style> 

답변

0

내가 그 SITE_URL을이 방식으로 작동하지 않습니다 생각하지. 이 함수는 도메인을 추측하고 사용자가 지정한 인수 앞에 추가합니다. 당신이 시도해야합니다

site_url("seatingreport4/index.php/help"); 

그것은이

http://localhost/seatingreport4/index.php/help 

를 다음 또는 당신이 CodeIgniter의에서 PDF를 생성 mPDF를 사용할 수있는 SITE_URL에 기능이없는

file_get_contents("http://localhost/seatingreport4/index.php/help"); 
+0

; //이 적어도 HTTP "( 'file_get_contents을 시도 – user2982187

+0

을 했로드 : // localhost를/seatingreport4/색인 .php/help ");'? – Kalzem

-2

쓰기 생성합니다.

컨트롤러 클래스를 만든 다음 컨트롤러 클래스를 만들 수 있습니다. 그리고 뭔가를 노호 코드를 할 -

public function mypdf() { 
    $this->load->library('pdf'); 
    $pdf = $this->pdf->load(); 
    $html=$this->load->view('welcome_message',null,true); 
    $pdf->WriteHTML($html); 
    // write the HTML into the PDF 
    $output = 'itemreport' . date('Y_m_d_H_i_s') . '_.pdf'; 
    $pdf->Output("$output", 'I'); 
} 

더 자세히 위해 당신은 mPDF의 CodeIgniter의 here에 대한 자습서를 볼 수 있습니다. 그렇지 PDF $ this->로드 ->보기 ('help_view')를 help_view하는 redirectig됩니다

관련 문제