迁移到另一台服务器

时间:2015-09-28 14:09:41

标签: php pdf dompdf

以下网站 - http://michigan.selfit.org/team-profiles/?division=2 当您点击任何一所学校组成的PDF文档时,会显示一些统计信息并显示在新标签中。文档示例 - http://michigan.selfit.org/team-profiles/?schoolid=133

生成以下内容的代码:

<?php

set_include_path(get_include_path() . PATH_SEPARATOR . "./dompdf"); // path to DomPDF 
require_once "dompdf/dompdf_config.inc.php"; // config in folder DomPDF

@$id = $_GET[schoolid];
@$division = $_GET[div];

    global $wpdb;
    $first=date('Y');
    $next=date('Y')-1; 
    $year= $next.'-'.$first;

    if (!empty($id)) {

        $scl = $michigan_af->get_schools_id($id);
        $bd = $michigan_af->get_team_result();
        $school = $michigan_af->get_schools();
        $event_id = $michigan_af->get_event_id_school($id);
        $count_bd = 0;
        $count_school = 0;
        $event_show = array();


        for ($i = 0; $i < count($bd); $i++) {
            if ($bd[$i]->division_id == $division) {
                $school_id[$count_bd] = $bd[$i]->school_id;
                $r1[$count_bd] = $bd[$i]->round_one;
                $r2[$count_bd] = $bd[$i]->round_two;
                $r3[$count_bd] = $bd[$i]->round_three;
                $total[$count_bd] = $bd[$i]->total;
                $event[$count_bd] = $bd[$i]->event_id;
                $date[$count_bd] = $bd[$i]->date;
                $count_bd++;
            }
        }


        $name=str_replace(" ","_",$scl->school_name);
        $school_logo=str_replace("http://michigan.selfit.org", $_SERVER["DOCUMENT_ROOT"],$scl->image);

        $get_team_result_for_pdf=$wpdb->get_results("SELECT `wp_team_results`.*,`wp_events`.`event_name` FROM `wp_team_results`,`wp_events` WHERE `wp_team_results`.`event_id`=`wp_events`.`id`  and `wp_team_results`.`school_id` = {$id} AND `wp_team_results`.`season` = '{$year}' AND `wp_team_results`.`division_id` = (select `id` from `wp_divisions` where `division_name` =(select `division` from `wp_schools` where `id`={$id})) AND `wp_team_results`.`currentstatus` = 0 AND `wp_team_results`.`status` LIKE 'y'");
        foreach ($get_team_result_for_pdf as $key => $value) {
            array_push( $event_show, '<tr><td>'.date('M-d-Y' ,strtotime($value->date)).'</td><td>'.$value->event_name.'</td><td>Division '.$value->division_id.'</td><td>'.$value->round_one.'</td><td>'.$value->round_two.'</td><td>'.$value->round_three.'</td><td>'.$value->total.'</td></tr><br>');
        }


                $html = '
        <div style="height: 90px; width: 100%; border: 1px solid grey; position: absolute; font-family:helvetica,sans serif;">
            <div style="width: 20%; height: 90px;">
                <img src="'.$school_logo.'" style ="height:85px; width:90px" />
            </div>
            <div style="width: 80%; margin-left: 20%; height: 90px; position: absolute; ">
                <span><b>'.$scl->school_name.'</b></span><br>
                <span>'.$scl->school_address.'</span><br>
                <span>'.$scl->contact_number.'</span><br>
            </div>
        </div>
        <div style="width: 100%; font-size: 15px; margin-top: 90px; border: 1px solid grey; font-family:helvetica,sans serif;">
            <table style="width: 100%; position: absolute; position: relative;">
                <tr><td>School web site:</td><td><a href="'.$scl->school_website.'">'.$scl->school_website.'</a></td></tr>
                <tr><td>Team web site: </td><td><a href="'.$scl->team_website.'">'.$scl->team_website.'</a></td></tr>
                <tr><td>Colors: </td><td>'.$scl->colors.'</td></tr>
                <tr><td>Conference: </td><td>'.$scl->conference.'</td></tr>
                <tr><td>Class: </td><td>'.$scl->class.'</td></tr>
                <tr><td>Enrollment: </td><td>'.$scl->enrollnment.'</td></tr>
                <tr><td>Division: </td><td>'.$scl->division.'</td></tr>
                <tr><td>Region: </td><td>'.$scl->region.'</td></tr>
                <tr><td>District:</td><td>'.$scl->district.'</td></tr>
                <tr><td>Head Coach: </td><td>'.$scl->head_coach.'</td></tr>
                <tr><td>Assistant Coaches: </td><td>'.$scl->assistant_coaches.'</td></tr>
                <tr><td>Team Accomplishments: </td><td>'.$scl->team_accomplishments.'</td></tr>
                <tr><td>Other: </td><td>'.$scl->other.'</td></tr>
                     <!-- Events -->
            </table>
            <table style="width: 100%; margin-top: 20px;">
                <tr><td>Date</td><td>Event</td><td>Division</td><td>Round 1</td><td>Round 2</td><td>Round 3</td><td>Total</td></tr>
                '.implode($event_show).'
            </table>
        </div>';

        $dompdf = new DOMPDF();
        $paper_size = array(0,0,800, 800); // page size - point per inch, maybe 
        $dompdf->set_paper($paper_size);
        $dompdf->load_html($html); // html code       
        $dompdf->render();
        $dompdf->stream($name.".pdf",array('Attachment'=>0));  
    }
?>

将此站点迁移到另一台服务器后,不会生成PDF文档,并输出文档的文本内容

  

%PDF-1.3 1 0 obj&lt;&lt; /类型/目录/概述2 0 R /页3 0 R&gt;&gt;   endobj 2 0 obj&lt;&lt; /类型/轮廓/计数0&gt;&gt; endobj 3 0 obj&lt;&lt; /类型   / Pages / Kids [6 0 R] / Count 1 / Resources&lt;&lt; / ProcSet 4 0 R / Font&lt;&lt;

可能出现什么问题?大约一个月寻找这个问题的答案。谷歌没有帮助。请告知可能的选项。 附:我正在使用DomPdf 0.6      服务器配置显示在选项卡&#34;链接

1 个答案:

答案 0 :(得分:0)

我成功打开了您的pdf文件。

无论如何都要尝试为响应设置标题:

    $dompdf->render();
    header('Content-Type: application/pdf');
    $dompdf->stream($name.".pdf",array('Attachment'=>0));