簡體   English   中英

FPDF pdf文件打開

[英]FPDF pdf file opening

“ Adob​​e Reader無法打開,因為它不是受支持的文件類型”

Php Fpdf文件已生成,但不是通過Adobe Reader打開,而是通過瀏覽器和其他pdf閱讀器打開,有什么想法嗎?

 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(); } 

誰能幫助解決這個問題

我把它用來解決此問題,因為開始(ob_clean)不會更改PDF結構:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM