加载PDF文档时发生错误

I would like you to help me with this problem.

I have some time working with a project in Laravel 5.6. This week I installed the barryvdh / laravel-dompdf package via composer as indicated in the documentation. I added the respective service provider in the config \ app.php file.

When trying to use the package for the first time I get the following error in Chrome: "An error occurred while loading the PDF document"

When I download the document and visualize it with a text editor, I realize that the only thing that is wrong with the file is that it lacks the first line:% PDF-1.3. When adding said line manually the document is "fixed".

To continue testing, I installed a new laravel project, and then I installed the package and created a route with the same code from the previous project. To my surprise, this project does load the PDF document in Chrome.

Please give me some idea of ​​what things I can review.

Thank you very much

展开翻译

译文

我希望你能帮我解决这个问题。</ p>

我有 有时候在Laravel 5.6中使用一个项目。 本周我按照文档中的说明通过composer安装了barryvdh / laravel-dompdf软件包。
我在config \ app.php文件中添加了相应的服务提供程序。</ p>

尝试使用时 该软件包首次在Chrome中出现以下错误:
“加载PDF文档时出错”</ p>

当我下载文档并使用文本编辑器将其可视化时, 我意识到该文件唯一错误的是它缺少第一行:%PDF-1.3。 当手动添加所述行时,文档被“修复”。</ p>

为了继续测试,我安装了一个新的laravel项目,然后我安装了包并使用相同的代码创建了一个路径。 以前的项目。 令我惊讶的是,这个项目确实在Chrome中加载了PDF文档。</ p>

请告诉我一些我可以查看的内容。</ p>

非常感谢</ p>
</ div>

dongwu9647
dongwu9647 我认为这与barryvdh/laravel-dompdf软件包无关,因为问题仍然存在于未使用dompdf创建的PDF文件中。我非常感谢你能给我的任何想法。
大约一年之前 回复

1个回答

I have already solved it. The cause of the problem was that the config/app.php configuration file did not have the <?php line at startup, and this was what caused the problem.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问