- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我们单击链接时,我们要下载Pdf格式的php页面数据。
因此,我们从官方git hub link下载了TCPDF
我们将提取的文件夹复制到路径:“ / var / www / html / sbdev2 / php / site6”
当我们在浏览器中运行示例代码:http://sbdev2.kidsdial.com:81/php/site6/tcpdf/examples/example_011.php时,我们可以下载pdf。
当我们在另一条路径http://sbdev2.kidsdial.com:81/php/site6/example_011.php中尝试相同的代码时,在行中出现“ Fatal error: Class 'TCPDF' not found
in”错误:类MYPDF扩展了TCPDF {
我检查了link,但这对我不起作用。
我也检查了link2并通过composer安装了TCPDF,如下图。但仍然存在该错误。
example_011.php
require_once('tcpdf_config.php');
// extend TCPF with custom functions
class MYPDF extends TCPDF {
// Load table data from file
public function LoadData($file) {
// Read file lines
$lines = file($file);
$data = array();
foreach($lines as $line) {
$data[] = explode(';', chop($line));
}
return $data;
}
// Colored table
public function ColoredTable($header,$data) {
// Colors, line width and bold font
$this->SetFillColor(255, 0, 0);
// Header
$w = array(40, 35, 40, 45);
$num_headers = count($header);
for($i = 0; $i < $num_headers; ++$i) {
$this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
}
$this->Ln();
// Color and font restoration
$this->SetFillColor(224, 235, 255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = 0;
foreach($data as $row) {
$this->Cell($w[0], 6, $row[0], 'LR', 0, 'L', $fill);
$fill=!$fill;
}
$this->Cell(array_sum($w), 0, '', 'T');
}
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 011', 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));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// 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('helvetica', '', 12);
// add a page
$pdf->AddPage();
// column titles
$header = array('Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)');
// data loading
$data = $pdf->LoadData('data/table_data_demo.txt');
// print colored table
$pdf->ColoredTable($header, $data);
// ---------------------------------------------------------
// close and output PDF document
$pdf->Output('example_011.pdf', 'I');
require_once('config/tcpdf_config_alt.php');
// Include the main TCPDF library (search the library on the following directories).
$tcpdf_include_dirs = array(
realpath('../tcpdf.php'),
'/usr/share/php/tcpdf/tcpdf.php',
'/usr/share/tcpdf/tcpdf.php',
'/usr/share/php-tcpdf/tcpdf.php',
'/var/www/tcpdf/tcpdf.php',
'/var/www/html/tcpdf/tcpdf.php',
'/usr/local/apache2/htdocs/tcpdf/tcpdf.php'
);
foreach ($tcpdf_include_dirs as $tcpdf_include_path) {
if (@file_exists($tcpdf_include_path)) {
require_once($tcpdf_include_path);
break;
}
}
/var/www/html/sbdev2/php/site6/tcpdf/example1
/var/www/html/sbdev2/php/site6/tcpdf/example1
最佳答案
我也遇到了这个问题,终于找到了解决方案。
一切都很好,让每个文件都只保留其原始路径,只需要打开tcpdf_include.php并包含文件tcpdf.php,仅此而已!
require_once(...安装目录... \ tcpdf.php');
一切都会好的
关于php - fatal error :在另一个路径中找不到类“TCPDF”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41298752/
我相信 TCPDF 中没有本地方法来创建阴影。我有什么想法可以用其他方法创造这样的效果吗?我首先考虑在每个边缘(对于矩形)旁边创建一个小渐变,但发现没有办法创建具有不同 Alpha channel 的
我已经通读了之前关于该主题的主题,但都是陈旧的、未回答的和/或关于创建自定义字体的更具体的内容。 在 TCPDF 中: $pdf->SetFont('times', '', 10); 我创建的 pdf
在 TCPDF 中有 GetCellHeight()用于测量细胞的高度。 如何测量 TCPDF 中字符串(或字符串块)的长度或宽度? 最佳答案 获取字符串长度的方法是 GetStringWidth()
我正在设置 tcpdf 来为客户即时生成发票,但是当我添加图像时,边框从我的表格中消失了。这是代码: /* if ($status == "Paid") { $pdf->Image("/wp-
我正在使用 TCPDF 生成 pdf。我可以使用 SetMargins($left, $top, $right = -1, $keepmargins = false) 为左、上和右设置边距,但不能为底
我正在使用 TCPDF 生成 pdf。我可以使用 SetMargins($left, $top, $right = -1, $keepmargins = false) 为左、上和右设置边距,但不能为底
从版本 5.9 开始,我还没有找到控制 TCPDF 的 MultiCell 中行距的方法。我也没有找到任何有助于通过使用 Cell 来模拟相同行为的方法,例如返回不适合 Cell 宽度的文本部分的方法
我正在努力了解 header 函数在 tcpdf 中的工作方式。 是否可以将 $pdf->writeHTML 用于标题? http://www.tcpdf.org/examples/example_0
为了创建自定义页眉和页脚,我使用了 TCPDF 的 header()和 footer()函数,但是当我尝试使用函数 $this->image() 在标题中包含图像时, 无法显示图像。文档中的其他图像工
我正在使用 tcpdf 用 PHP 生成 PDF 文件,并且以 .svg 文件的形式嵌入 SVG 图像没有问题,其中包含表示图像的 XML 标记。但是,我希望能够使用该 XML,例如作为 PHP 字符
关于此的主题有很多,但没有一个能解决我的问题。我想做的很简单 - 生成一个条形图,然后将该图嵌入到一个 pdf 文件中,我将使用名为 TCPDF 的库生成该文件。 . 我使用 TCPDF 生成 HTM
第一张图片显示了使用 TCPDF 时的标准 header 布局: 我想做的是右对齐文本,如下所示,但我无法弄清楚如何做到这一点: 请大家给点建议!谢谢。 最佳答案 实现此目的的一种方法是使用 writ
我花了一个多小时研究这个问题,但似乎找不到答案。 我在 TCPDF 中使用 writeHTMLCell 。使用 writeHTMLCell 时,我需要一些文本以适合特定区域。 我见过一个例子here
我正在使用 TCPDF 从 HTML 代码生成 PDF,但无法正确呈现某些 HTML 特殊字符。这是我的准系统代码: require_once('../libraries/tcpdf_6_0_020/
我有以下 svg 文件: http://jsfiddle.net/wptn28c5/ 呈现: 但是,通过使用 tcpdf ($pdf->imageSVG()) 我得到一个呈现的 pdf 文件: 最佳
如何导入现有 pdf文件到新创建的 pdf使用 TCPDF? 所以假设我目前正在做发票部分。一旦用户点击打印发票,我将开始收集数据,然后创建一个 PDF使用 TCPDF .但是,如果可用,我需要“附加
我有以下 tcpdf 代码: SetCreator(PDF_CREATOR); $pdf->SetAuthor('Stimart'); $pdf->SetTitle('test
有谁知道如何使用 PHP TCPDF 导出 PDF/X-1a:2001 PDF 文件图书馆。我研究了很多,但找不到解决方案。有人请指教。解决方案需要在 PHP 中。 最佳答案 我不是 TCPDF 方面
我有一个基于数据生成 PDF 文件的网站。 我在一个免费的虚拟主机上试过了,没问题,但是当我把它上传到我的服务器时,我得到了这个错误: TCPDF 错误:无法打开图像文件:/var/www/html/
我正在使用 TCPDF 来签署 PDF,但是在运行 example 52 时我收到此错误: Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-
我是一名优秀的程序员,十分优秀!