2015-01-28 5 views
1

임은 mpdf 라이브러리를 사용하여 PDF 파일을 구축하려는 이미지를 사용하여 ... mpdf 부문

 include('convert-to-pdf/mpdf.php'); 


     // build the content for the preview... 

     ob_start(); 

       include (DIR_BOOKS.'/'.$book_path.'/preview-male.php'); 
       $html = ob_get_contents(); 
     ob_end_clean(); 

     // build the overlay on the child image 

     $mpdf=new mPDF('utf-8', array(221,221)); 


     $stylesheet = file_get_contents(DIR_BOOKS.$book_path.'/stylesheet.css'); 
     $mpdf->WriteHTML($stylesheet,1);  
     $mpdf->WriteHTML($html,2);  

     $mpdf->Output(DIR_TEMPORARY_IMAGES.$this->session->data['pdf_id'].'.pdf','F'); 

그리고 임 오류를 받고 mpdf의 코드 ...

$this->WriteHTML($html , 4); // parameter 4 saves output to $this->headerbuffer 
$actual_h = $this->y - $y; 
$use_w = $w; 
$use_h = $h; 

//Line 13865 
$ratio = $actual_h/$use_w; 

if ($overflow!='hidden' && $overflow!='visible') { 
    //Line 13868 
    $target = $h/$w; 
    if (($ratio/$target) > 1) { 
     $nl = CEIL($actual_h/$this->lineheight); 
     $l = $use_w * $nl; 
     $est_w = sqrt(($l * $this->lineheight)/$target) * 0.8; 
     $use_w += ($est_w - $use_w) - ($w/100); 
    } 
    //Line 13875 
    $bpcstart = ($ratio/$target); 
    $bpcctr = 1; 
    while(($ratio/$target) > 1) { 

     if ($this->progressBar) { $this->UpdateProgressBar(4,intval(100/($ratio/$target)),('Auto-sizing fixed-position block: '.$bpcctr++)); } // *PROGRESS-BAR* 

     $this->x = $x; 
     $this->y = $y; 

     if (($ratio/$target) > 1.5 || ($ratio/$target) < 0.6) { 
      $use_w += ($w/$this->incrementFPR1); 
     } 
     else if (($ratio/$target) > 1.2 || ($ratio/$target) < 0.85) { 
      $use_w += ($w/$this->incrementFPR2); 
     } 
     //Line 13890 
     else if (($ratio/$target) > 1.1 || ($ratio/$target) < 0.91) { 
      $use_w += ($w/$this->incrementFPR3); 
     } 
     else { 
      $use_w += ($w/$this->incrementFPR4); 
     } 

     $use_h = $use_w * $target ; 
     $this->rMargin=$this->w - $use_w - $x; 
     $this->pgwidth = $this->w - $this->lMargin - $this->rMargin; 
     $this->HTMLheaderPageLinks = array(); 
     $this->HTMLheaderPageAnnots = array(); 
     $this->HTMLheaderPageForms = array(); 
     $this->pageBackgrounds = array(); 
     $this->WriteHTML($html , 4); // parameter 4 saves output to $this->headerbuffer 
     $actual_h = $this->y - $y; 
     $ratio = $actual_h/$use_w; 
    } 
    if ($this->progressBar) { $this->UpdateProgressBar(4,'100',' '); } // *PROGRESS-BAR* 
} 
$shrink_f = $w/$use_w; 

그리고 에서 HTML을 가져 오는 메신저 내 PHP 파일 ...

<div class="page-1-image-1"><img src="https://www.example.com/working-image.jpg" /> </div> 

임 내 mpdf의 HTML 코드에 이미지를 포함 할 때 다음과 같은 오류가 점점 ...

<b>Warning</b>: Division by zero in <b>/var/www/html/example/mpdf.php</b> on line <b>13865</b> 
<b>Warning</b>: Division by zero in <b>/var/www/html/example/mpdf.php</b> on line <b>13868</b> 
<b>Warning</b>: Division by zero in <b>/var/www/html/example/mpdf.php</b> on line <b>13869</b> 
<b>Warning</b>: Division by zero in <b>/var/www/html/example/mpdf.php</b> on line <b>13875</b> 
<b>Warning</b>: Division by zero in <b>/var/www/html/example/stuff.php</b> on line <b>13877</b> 
<b>Warning</b>: Division by zero in <b>/var/www/html/example/mpdf.php</b> on line <b>13910</b> 
<B>mPDF error: </B>Please do not use values equal to zero for scaling 

갓 생성 된 내 자신의 이미지를 모두 시도했지만 온라인에서도 완벽하게 좋은 이미지 URL을 시도했지만 기쁨이 없었습니다. 나는 pngs와 jpgs를 시도했다.

Im 이러한 오류는 단순히 이미지를로드하지 않는 문제에서 비롯된 것으로 의심됩니다. 미리 감사드립니다.

+0

이 우리에게 보여주십시오'stuff.php' 라인 :'13860' - 당신 말이 있지만 위해서는 아마있어'13915' – Rizier123

+0

을 사람들이 당신을 도울 수 있다면, 어떻게 오류가 발생했는지 보여줄 필요가 있습니다. 쇼 코드! – BigScar

+0

사과, mpdf.php에 stuff.php를 변경하여 더 명확하게하고 일부 코드를 게시 할 예정입니다. – Adrian

답변

0

그래서 무슨 일이 일어나고있는 것은 0으로 숫자를 나눌 것인가? 수학에서는 허용되지 않습니다. (예를 들어, 5/0 = ? -> ? * 0 = 5)

예를 들어이 라인 :

$ratio = $actual_h/$use_w; 

$use_w가 0이기 때문에 당신은 오류가! 그렇다면 이러한 오류를 어떻게 막을 수 있습니까?


당신은이 같은 검사 할 수 있습니다 :

if($use_w != 0) { 
    //Here you could end the script OR assign it to 1, just make sure you never use $use_w with the value 0 
    $ratio = $actual_h/$use_w; 
} 
+0

감사합니다. 도움을 주셔서 감사합니다.하지만 주요 이슈 Im은 첫 번째 장소에서 0을 발생시키는 것입니다. pdf를 생성하는 데 사용되는 html 코드에 이미지가 포함 된 것으로 보입니다. – Adrian

+1

@Adrian 나는 더 이상 당신을 도울 수 없다, 나는 단지 당신이 0이라는 가치가 없다는 것을 확인해야한다고 말할 수있다. 그것이 mpdf의 버그/문제라면, 나는 당신을 도울 수 없다. – Rizier123

+0

이것은 기술적으로 정답이다 다른 사람이 그 PHP 오류와 함께 도착하는 경우, 당신을 감사합니다 – Adrian