编程语言
首页 > 编程语言> > php-如何正确使用laravel-dompdf生成视图pdf

php-如何正确使用laravel-dompdf生成视图pdf

作者:互联网

我有以下观点

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>
<ul class="nav nav-tabs">
    <li role="presentation" class="active"><a href="#">Home</a></li>
    <li role="presentation"><a href="#">Profile</a></li>
    <li role="presentation"><a href="#">Messages</a></li>
</ul>
<form>
    <div class="form-group">
        <label for="exampleInputEmail1">Email address</label>
        <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
    </div>
    <div class="form-group">
        <label for="exampleInputPassword1">Password</label>
        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
</form>
</body>
</html>

并使用以下代码生成pdf文件

public function pdf()
{
    $view = view()->make('Article::print');
    $contents = $view->render();
    $pdf = PDF::loadHTML($contents)->setPaper('a4', 'landscape')->setWarnings(false);
    return $pdf->download('santosh.pdf');
}

但是它没有给出正确的输出,而是返回Returned PDF view

我该如何解决,请帮忙

解决方法:

当前版本的Dompdf(0.7.0)对基于Bootstrap的样式提供了有限的支持(请参见relevant issue).使用0.7.1,Dompdf将更接近能够呈现您的文档的功能,但我仍然不建议您使用以下版本(0.7.2?),因为它仍然缺少一些关于框大小CSS的必要功能.属性.

标签:laravel-5,pdf,dompdf,php
来源: https://codeday.me/bug/20191111/2022846.html