我再次遇到PHP问题。
我正在制作PDF,我必须在网页上显示也会出现的图片。
问题是图像没有在PDF上显示。
实际上它是一种不同的图像,实际上更像是图表。
您在网页中执行的所有操作都显示在图表中,我必须将其打印在PDF中,但PDF只是忽略了打印命令。
HTML代码示例(工作得很好):
<html>
<h3>
you can take files copies in xls or Pdf format
</h3>
<br> <a href="../useful/excel.php"> Generate excel file</a> <br> <BR>
<form method="post" action="" target="_blank">
<input type="submit" name="pdf" value="generate PDF " />
<input type="hidden" id="hide" name="hide">
</form><br>
<center><div id="image" name="image"><img src="../useful/createchart.php"/></div> </center>
</html>
正如您所看到的,它使用PHP文件来创建图表(这不是一个类,它只是一个带有一些方法的PHP文件)。
所以我对于我要对PDF中显示的图像做了什么无能为力。
顺便说一下,我正在使用mPDF。
在这里,我有一部分代码来打印PDF,这就是重要的部分。它可以很好地打印表格,但它根本不打印图像。
<?php // create PDF report ...
if (isset($_POST['pdf'])){
$mpdf = new mPDF();
//foreach ($showmore as $items){
$array = explode('-', $store);
//$Result = array();
foreach ($array as $member){
if($member != '')
$res= $dao->getinfobynumber ('jc', $member);
//var_dump($res);
foreach ($res as $jcvalue){
$mpdf->SetHeader("Tabela");
$mpdf->SetFooter(date('l jS \of F Y h:i:s A'));
$htmlpdf2 .= "
<table border='1'>
<tr>
<th width='150'>GE</th>
<td width='200'>". $jcvalue->getsg()."</td>
<td width='200'><strong>Nome Curto</strong></td>
<td width='200'>". $jcvalue->getnomecurto()."</td>
</tr>
</table>
<table border='1'>
<tr>
<th width='150'>Valor</th>
<td width='200'>". $jcvalue->getpvalor() ."</td>
<td width='200'><strong>FC</strong></td>
<td width='200'>". $jcvalue->getfc() ."</td>
</tr>
</table>
<table border='1'>
<tr>
<th width='150'> Jugular </th>
<td width='117'>". $jcvalue->getjugular1() ."</td>
<td width='117'>". $jcvalue->getjugular2() ."</td>
<td width='117'>". $jcvalue->getjugular3() ."</td>
<td width='118'>". $jcvalue->getjugular4() ."</td>
<td width='119'>". $jcvalue->getjugular5() ."</td>
</tr>
</table>
<table border='1'>
<tr>
<th width='150'>EXP3D</th>
<td width='200'>". $jcvalue->getd3_1() ."</td>
<td width='200'>". $jcvalue->getd3_2() ."</td>
<td width='200'>". $jcvalue->getd3_3() ."</td>
</tr>
</table>
<table border='1'>
<tr>
<th width='150'>EXP28D</th>
<td width='200'>". $jcvalue->getd28_1() ."</td>
<td width='200'>". $jcvalue->getd28_2() ."</td>
<td width='200'>". $jcvalue->getd28_3() ."</td>
</tr>
</table>
<table border='1'>
<tr>
<th width='150'>Carotida</th>
<td width='303'>". $jcvalue->getcarotida_1() ."</td>
<td width='303'>". $jcvalue->getcarotida_2() ."</td>
</tr>
</table>
<br><br>";
}
}
$PDFimage = "<center><div id='image' name='image'><img src='../useful/createchart.php'/></div></center>";
$mpdf->WriteHTML($htmlpdf2);
$mpdf->WriteHTML($PDFimage);
$mpdf->Output();
}
这里是使用网页选择你想要看到的内容的代码,apge会根据你选择的内容和基于数据的图表来提供所有数据:
<?php session_start();
//this file contains the full information for the sample
// will include in this file simple table contains all informations
// also will calling function from creat table and also will call function create chart and export to excel
require_once '../useful/createtable.php';
require_once '../dao/bancojc_424_dao.php';
require_once '../model/jcdrow.php';
require_once '../model/jc.php';
include("../useful/MPDF57/MPDF57/mpdf.php");
require_once '../dao/meta.php';
?>
<?php
$table = new createtable();
$dao = new daobancojc();
$meta = new metachart();
$meta->resetmeta();
$showmore =explode('-', $_GET['data']);
$showtable =explode('-', $_GET['table']);
$t='';
$htmlpdf='';
foreach($showmore as $item ){
if ($item !=''){
foreach($showtable as $tables)
if($tables == 'jc')
{
$result=$dao->getinfobynumber ('jc', $item);
$t='jc';
}elseif ($tables == 'j3d'){
$result=$dao->getinfobynumber ('j3d', $item);
$t='j3d';
}elseif($tables == 'j28d'){
$result=$dao->getinfobynumber ('j28d', $item);
$t='j28d';
}
$store .= '';
foreach ($result as $return){
$meta->insertmeta($t,$return->getsg());
$htmlpdf= 'No:'.$return->getsg(). '<br>';
$htmlpdf.= 'Nome Curto: '.$return->getnomecurto().' Nome Longo : ';
$htmlpdf.= $return->getnomelongo();
echo $htmlpdf;
?>
<table class="tabela_registros1" border=1 width=80% ><?php
$htmlpdf.= $table->morejc($return);
echo $htmlpdf;
?>
</table> <?php $store .= '-'.$return->getsg() ;
}