在TCPDF中创建的PDF无法在AdobeReader中打开

时间:2017-03-20 09:34:30

标签: php tcpdf

我有PHP代码,可以使用TCPDF动态创建PHP文件。

public function createRegulationPDF(){
    require_once('TCPDF/tcpdf.php');
    $pageDimension = array('500,300'); //width,height
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);        
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor('CopyrightPolska.com.pl');
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);    
    $pdf->SetFont('freeserif', '', 12);
    $width = $pdf->pixelsToUnits(768); 
    $height = $pdf->pixelsToUnits(1024);
    $resolution= array($width, $height);
    $pdf->AddPage('P', $resolution);
    $html = $this->view->render('index/summaryForPDF.phtml');
    $pdf->writeHTML($html, true, false, true, false, '');       
    $pdf->Output('exampleDownloaded.pdf', 'D');
    return $pdf;
}

接下来,这个PDF将作为exampleDownloaded.pdf下载并且(同时)附加到电子邮件中:

$filename = "exampleAttached.pdf";
        // encode data (puts attachment in proper format)
        $pdfdoc = $pdf->Output("", "S");
        $attachment = chunk_split(base64_encode($pdfdoc));

我尝试在AdobeReader中打开文件 1. exampleDownloaded - 无法在Adobe中打开 pdferror.png 2. exampleAttached - 打开没有任何问题

有人知道为什么PDF下载不能打开吗?

0 个答案:

没有答案