【发布时间】:2019-07-23 09:09:58
【问题描述】:
我创建了一个插件,当你按下发送时,表格中的数据应该被翻译成 pdf 并保存在一个文件夹中以供备份。
我正在使用 tcpdf api,下载了库并将其放在我的插件文件夹中。当我尝试使用来自 tcpdf 站点的 givin textexample 对其进行测试时,它只会抛出这些错误:
“警告:“继续”定位开关等同于“中断”。确实 你的意思是使用“继续2”?在 /www/htdocs/w00e68de/msp.rfid-dresden.de/wp-content/plugins/wp-markenbuero/tcpdf/tcpdf.php 上线17778
警告:fopen():不支持远程主机文件访问, 文件://example_002.pdf 在 /www/htdocs/w00e68de/msp.rfid-dresden.de/wp-content/plugins/wp-markenbuero/tcpdf/include/tcpdf_static.php 在线 1854
警告:fopen(file://example_002.pdf):打开流失败:否 合适的包装可以在 /www/htdocs/w00e68de/msp.rfid-dresden.de/wp-content/plugins/wp-markenbuero/tcpdf/include/tcpdf_static.php 在第 1854 行 TCPDF 错误:无法创建输出文件: example_002.pdf"
// Include the main TCPDF library (search for installation path).
require_once('tcpdf/tcpdf.php');
// 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('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 002');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// 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('times', 'BI', 20);
// add a page
$pdf->AddPage();
// set some text to print
$txt = <<<EOD
TCPDF Example 002
Default page header and footer are disabled using setPrintHeader() and setPrintFooter() methods.
EOD;
// print a block of text using Write()
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_002.pdf', 'F');
}
?>
【问题讨论】:
-
1.确保您已启用
fopen以打开 URL; 2. 这是警告,而不是错误。您可以关闭错误报告,它将被禁止。 3. 可能是插件不安全,实际上在文件 tcpdf.php 的第 17778 行抛出警告