2017-05-15 5 views
0

「それはサポートされているファイルの種類のいずれかではありませんbeacuse Adob​​e Readerは開くことができませんでした」をFPDFのpdfファイルを開く

PHPのFPDFファイルを生成しているが、それは、ブラウザや他のPDFリーダーを経由してのAdobe Readerが、開口を介して任意のアイデアを開いていません?

function viewfortressmonthly($datese, $location_idnew) { 
 
    
 
     $companyid = $_SESSION['companyid']; 
 
     $pieces = explode("-", $location_idnew); 
 
     $location_id = $pieces[0]; 
 
     $site_id = $pieces[1]; 
 
     $this->selectLocationFromSite($companyid, $site_id, $location_id); 
 
     $monthnumber = substr($datese, 2, 2); 
 
     $monthname = date('F', strtotime("2000-$monthnumber-01")); 
 

 
     if (substr($datese, 2, 2) == "01" || substr($datese, 2, 2) == "03" || substr($datese, 2, 2) == "05" || substr($datese, 2, 2) == "07" || substr($datese, 2, 2) == "08" || substr($datese, 2, 2) == "10" || substr($datese, 2, 2) == "12") { 
 
      $array_day = array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"); 
 
     } else if (substr($datese, 2, 2) == "04" || substr($datese, 2, 2) == "06" || substr($datese, 2, 2) == "09" || substr($datese, 2, 2) == "11") { 
 
      $array_day = array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"); 
 
     } else { 
 
      $array_day = array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"); 
 
     } 
 
     $array_time = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); 
 
     $conn = new mysqli($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName) or die('error connect'); 
 
     
 
     $pdf = new PDF("L", "in", "A4"); 
 
     $pdf->SetMargins(.1, .05, .05); 
 
     $pdf->AddFont('gothic', '', 'gothic.php'); 
 
     $pdf->AddPage(); 
 
     $pdf->SetFillColor(255, 255, 255); 
 
     $pdf->AddFont('UNIVERS0_0', '', 'UNIVERS0_0.php'); 
 
     $pdf->SetFont('UNIVERS0_0', 'U', 18); 
 
     $pdf->SetFont('gothic', '', 16); 
 
     $pdf->Cell(7.7, .30, 'PATROL RECORDS-' . "20" . substr($datese, 0, 2) . "-" . substr($datese, 2, 2) . "[" . $monthname . "]", 0, 2, "C", 1); 
 
     $pdf->Cell(7.7, .30, $this->location, 0, 2, "C", 1); 
 
     $pdf->SetFont('gothic', '', 10); 
 
     $pdf->Cell(.36, .25, "D/H", 'LTRB', 0, "C", 1); 
 
     foreach ($array_day as $days) { 
 
      $pdf->Cell(.36, .25, $days, 'LTRB', 0, "C", 1); 
 
     } 
 
     $pdf->Ln(); 
 
     $pdf->SetFont('gothic', '', 6); 
 
     for ($i = 0; $i < sizeof($array_time); $i++) { 
 
      $pdf->Cell(.36, .25, $array_time[$i], 'LTRB', 0, "C", 1); 
 
      foreach ($array_day as $days) { 
 
       $datefinal = $datese . $days . $array_time[$i]; 
 
       $query2 = "select DATETIME from $this->dbName.$this->dbViewTable where DATETIME LIKE '$datefinal%' AND COMPANY_ID='$companyid' AND SITE_ID='$site_id' AND LOCATION_ID='$location_id' order by ID DESC LIMIT 1"; 
 
       $result = $conn->query($query2); 
 
       $row2 = $result->fetch_assoc(); 
 
       $date = $row2['DATETIME']; 
 
       $timec = substr($date, 6, 2) . ":" . substr($date, 8, 2) . ":" . substr($date, 10, 2); 
 
       if ($timec == "::") { 
 
        $imagefill = "images/colors/bg.png"; 
 
        $pdf->Cell(.36, .25, "" . $pdf->Image($imagefill, $pdf->GetX(), $pdf->GetY(), .36, .25), 'LTBR', 0, 'C'); 
 
       } else { 
 
        $pdf->Cell(.36, .25, $timec, 'LTRB', 0, "C", 1); 
 
       } 
 
      } 
 
      $pdf->Ln(); 
 
     } 
 
     ob_clean(); 
 
     $pdf->Output("Reports-$location_id-$datese.pdf", 'D'); 
 
     $conn->close(); 
 
    }

いずれかのヘルプ解決には、この問題

+1

問題のトラブルシューティングに役立つ関連コードを投稿してください。 – cteski

+0

Check http://stackoverflow.com/q/22817210/1740715 – Harikrishnan

答えて

0

私はbeggining(ob_clean)でこの問題を解決するために、これをパットは、PDFの構造を変更しないことができます。

require('fpdf/fpdf.php'); 
ob_clean(); 
+0

これは疑問に答えるかもしれませんが、答えの本質的な部分を説明し、OPコードの問題点を説明する方が良いでしょう。 – pirho

関連する問題