【发布时间】:2020-01-30 04:07:51
【问题描述】:
所以它看起来像这样example
我应该遵循什么教程?
【问题讨论】:
-
我希望蓝色的字应该来自oracle数据库。但我还没有找到办法。我应该学习什么教程?
标签: oracle codeigniter fpdf
所以它看起来像这样example
我应该遵循什么教程?
【问题讨论】:
标签: oracle codeigniter fpdf
在文件夹“application/libraries”中创建一个名为'pdf.php'的文件,并放入以下代码
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
require_once APPPATH . "/third_party/tcpdf/tcpdf.php";
class Pdf extends tcpdf {
public function __construct() {
parent::__construct();
}
}
?>
在你的控制器中添加以下函数
public function createPDF($fileName,$html) {
ob_start();
// Include the main TCPDF library (search for installation path).
$this->load->library('Pdf');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('TcPdf');
$pdf->SetTitle('TcPdf');
$pdf->SetSubject('TcPdf');
$pdf->SetKeywords('TcPdf');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 0, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
// set auto page breaks
//$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetAutoPageBreak(TRUE, 0);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('dejavusans', '', 10);
// add a page
$pdf->AddPage();
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// reset pointer to the last page
$pdf->lastPage();
ob_end_clean();
//Close and output PDF document
$pdf->Output($fileName, 'F');
}
在 pdf 中准确创建视图并将其加载到控制器中以生成 pdf
$htmlContent = $this->load->view('views/your-view-file', $data, TRUE);
$createPDFFile = 'your-pdf-name'.'.pdf';
$this->createPDF('location-for-pdf'.$createPDFFile, $htmlContent);
这将在您提供的位置创建一个与您创建的视图完全相同的 pdf 文件。
【讨论】: