我使用了以下软件包将html转换为pdf:
https://github.com/vsmoraes/pdf-laravel5
但是当我用这个的时候,它根本不是在看。这是我原来的html pdf:

当我转换它时,它看起来是这样的:

我在这里做错什么了吗?
编辑:
public function __construct(Pdf $pdf)
{
$this->pdf = $pdf;
}
public function download()
{
$html = view('administration.invoice')->render();
return $this->pdf->load($html)->download();
}发布于 2016-01-16 17:10:45
这个laravel包似乎正在使用DOMPDF,这是很棒的。
请记住,我看不到您的代码,我将共享为我工作的PHP代码:
// This should be your normal HTML page
$url = 'http://www.website.com/invoice';
$html = file_get_contents($url);
// First. Convert all relative image paths to file system paths.
// Test that the generated path is where your images files are located
$html = str_replace("/images", public_path()."/images", $html);
// Generate PDF file
$dompdf = new DOMPDF();
$dompdf->set_paper("A4", "portrait");
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream('your_invoice_file.pdf');如果您还想直接呈现一个Laravel视图以PDF格式,请用这一行代码替换前两行代码
// Just render the view normally
$html = View::make('path/view');如果添加了代码,则可以选择其他选项。
$html = view('administration.invoice')->render();
$html = str_replace("/images", public_path()."/images", $html);
return $this->pdf->load($html)->download();请记住将“图像”文件夹设置为您拥有的文件夹。
https://stackoverflow.com/questions/34829446
复制相似问题