但是,当我尝试将以下内容保存为PDF时,无法正常工作。
<?php
session_start();
// User session check
if(!$_SESSION['email'])
{
header("Location: login.php");//redirect to login page to secure the welcome page without login access.
}
include("php/getCustomerEvents.php");
// get row id = student id
$id = $_GET[id];
// check user language
$lang = $_SESSION['lang'];
switch ($lang)
{
case 'en':
$lang_file = 'lang.en.php';
break;
//case 'fr':
//$lang_file = 'lang.fr.php';
//break;
case 'nl':
$lang_file = 'lang.nl.php';
break;
default:
$lang_file = 'lang.nl.php';
}
include_once 'lang/'.$lang_file;
// Debug code
//print_r($_SESSION);
//echo "----------------------------------------------------------------------->".$_SESSION['lang']." = taal <br>";
//echo "----------------------------------------------------------------------->".$_SESSION['name']." = naam <br>";
//echo "----------------------------------------------------------------------->".$_SESSION['resource']." = id <br>";
//Echo "----------------------------------------------------------------------->".$_SESSION['admin']." = admin <br>";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/bootstrap-select.css">
<style type="text/css">
.bs-example{
margin: 20px;
}
/* Fix alignment issue of label on extra small devices in Bootstrap 3.2 */
.form-horizontal .control-label{
padding-top: 7px;
}
</style>
</head>
<body >
<!-- Main content -->
<section class="content" >
<!-- Your Page Content Here -->
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $lang['LBL_LIST_EVENTS']; ?></h3>
</div><!-- /.box-header -->
<div class="box-body">
<table id="instructors" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th><?php echo $lang['LBL_LESSON']; ?></th>
<th><?php echo $lang['LBL_LOCATION']; ?></th>
<th><?php echo $lang['LBL_TITLE']; ?></th>
<th><?php echo $lang['LBL_EVENT_START']; ?></th>
<th><?php echo $lang['LBL_EVENT_END']; ?></th>
</tr>
</thead>
<tbody>
<?php customerevents($id); ?><!-- function from getCustomerEvents.php -->
</tbody>
</table>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" class="btn btn-success" ><span class="glyphicon glyphicon-print" aria-hidden="true"></span> PDF </button>
<button type="submit" class="btn btn-success" ><span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> MAIL </button>
</div><!-- /.box-footer -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
<!-- Main Footer -->
<footer class="main-footer">
<!-- To the right -->
<div class="pull-right hidden-xs">
</div>
<!-- Default to the left -->
<strong>Copyright © 2015 <a href="http:\\www.biqsit.be">biqs it</a>.</strong> All rights reserved.
</footer>
</body>
</html>
我使用的代码生成PDF:
<?php
require_once("../dompdf/dompdf_config.inc.php");
//$content = "../" . $_GET["content"];
//$file_name = $_GET["file_name"];
$dompdf = new DOMPDF();
//$html = file_get_contents($content);
$html = file_get_contents('../pdf_customer_events.php');
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
我做错了什么?还是DOMPDF不是正确的解决方案?
file_get_contents()
函数读取PHP
文件将会检索到未解析的PHP
代码。 - D4V1D