" Adobe 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();
}
&#13;
任何人都可以帮助解决此问题
答案 0 :(得分:0)
我推迟了这个来解决这个问题,在beggining(ob_clean)中没有改变PDF结构:
require('fpdf/fpdf.php');
ob_clean();