textarea中的dompdf表出错了吗?

时间:2013-06-26 11:11:18

标签: php javascript html dompdf

大家好,你们之前已经处理过 dompdf 因为我想要生成 PDF文件,其中包含一个包含数据库的表头的表,我试图把它放入它在文本区域但它不起作用,这是代码的一部分:

<textarea name="html" cols="60" rows="20">

<table cellpadding="1" cellspacing="1" id="resultTable" width="80%" height="20%">
                        <thead>
                            <tr>
                                <th  style="text-align:center;border-left: 1px solid #C1DAD7"> Plate Number </th>
                                <th style="text-align:center"> GPS ID </th>
                                <th style="text-align:center"> Coming Form </th>
                                <th style="text-align:center"> Going TO </th>
                                </tr>
                        </thead>
                                <tbody>
                                <?php
                                    include('db.php');
                                    $result = mysql_query("SELECT * FROM bus");
                                    while($row = mysql_fetch_array($result))
                                        {
                                            echo '<tr class="record">';
                                            echo '<td ><div align="center">'.$row['plate_number'].'</div></td>';
                                            echo '<td><div align="center">'.$row['GPS_id'].'</div></td>';
                                            echo '<td><div align="center">'.$row['Coming_from'].'</div></td>';
                                            echo '<td><div align="center">'.$row['destination'].'</div></td>';
                                            echo '</tr>';
                                        }
                                    ?>
                             </tbody>
                    </table>


<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">
<p>
<select name="paper">
<?php
foreach ( array_keys(CPDF_Adapter::$PAPER_SIZES) as $size )
  echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n";
?>
</select>
<select name="orientation">
  <option value="portrait">portrait</option>
  <option value="landscape">landscape</option>
</select>
</p>

</textarea> 

这是获取文本区域内容然后将其转换为 PDF 的地方:

<?php

require_once("../dompdf_config.inc.php");

// We check wether the user is accessing the demo locally
$local = array("::1", "127.0.0.1");
$is_local = in_array($_SERVER['REMOTE_ADDR'], $local);

if ( isset( $_POST["html"] ) && $is_local ) {

  if ( get_magic_quotes_gpc() )
    $_POST["html"] = stripslashes($_POST["html"]);

  $dompdf = new DOMPDF();
  $dompdf->load_html($_POST["html"]);
  $dompdf->set_paper($_POST["paper"], $_POST["orientation"]);
  $dompdf->render();
  $dompdf->stream("Report.pdf");

  exit(0);
}

?>

0 个答案:

没有答案