Php 将同一页转换为PDF
我想将同一文档转换为PDF,或者在url中添加post方法,如下所示:Php 将同一页转换为PDF,php,laravel,Php,Laravel,我想将同一文档转换为PDF,或者在url中添加post方法,如下所示: $dompdf->loadHtml($_POST['name']); 代码如下: <?php // include autoloader require_once 'dompdf/autoload.inc.php'; // reference the Dompdf namespace use Dompdf\Dompdf; // instantiate and use the dompdf class $do
$dompdf->loadHtml($_POST['name']);
代码如下:
<?php
// include autoloader
require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml(file_get_contents('http://localhost/));
// (Optional) Setup the paper size and orientation
$dompdf->setPaper(array(0,0,850,2250), 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
//$dompdf->stream();
// Output the generated PDF (1 = download and 0 = preview)
$dompdf->stream("codex",array("Attachment"=>0));
?>
如果文件获取内容,则行中缺少一个引号
<?php
// include autoloader
require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml(file_get_contents('http://localhost/'));
// (Optional) Setup the paper size and orientation
$dompdf->setPaper(array(0,0,850,2250), 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
//$dompdf->stream();
// Output the generated PDF (1 = download and 0 = preview)
$dompdf->stream("codex",array("Attachment"=>0));
?>
没错,那么问题出在哪里?您看到缺少的单引号了吗?颜色编码告诉你有一个问题不,没有任何问题,我可以用这个URL创建一个PDF,但我想在这里添加Post方法,这样我可以从HTML中添加URL,所以继续制作一个表单,你可以从中输入一个参数。哦,在这种情况下,我可以建议你去,并且已经在评论中提到过。这实际上并没有试图回答这个问题!在发表评论之前,我开始键入答案,并在评论之后发布。顺便说一句,如果你注意到报价丢失,它会工作吗?绝对不是。如果我纠正了它,就没有必要投反对票。我的回答是朝着正确的方向前进。第2句:这并不是试图回答问题,因为问题中的代码示例只是应用程序的一个片段。您永远不知道表单是否准备好了,只有缺少的报价会产生问题。向下投票只是阻止回答问题的尝试,这并不能回答问题。