简体   繁体   English

laravel 无法在刀片页面中加载 pdf 文件进行显示

[英]laravel can't load pdf file in blade page for diplaying

i tried to display pdf in "home.blade.php" page but it not displayed pdf but showing empty blank page.我试图在“home.blade.php”页面中显示 pdf,但它没有显示 pdf 而是显示空的空白页面。

i stored pdf file in "public" folder我将pdf文件存储在“public”文件夹中

i tried below 2 different codes but not work我尝试了以下 2 个不同的代码但不起作用

<iframe src="{{URL::to('/WEBSITE-FILE')}}/test.pdf" width="100%" height="600"></iframe>

<iframe src="WEBSITE-FILE/test.pdf" class="pdf-spacing-verify pdf-view-for-mainnet-verify" id="pdf_display_frame" width="100%" height="500px"></iframe>

Alright i thought something was wrong with my code when i try to display pdf in the browser, it was opening in google chrome browser but not in mozilla firefox so it turns out my pdf is in download mode and then i changed it into "Preview in firefox" .好吧,当我尝试在浏览器中显示 pdf 时,我认为我的代码有问题,它在 google chrome 浏览器中打开,但在 mozilla firefox 中没有打开,所以结果我的 pdf 处于下载模式,然后我将其更改为“预览火狐” Please check in both browser that pdf is in viewing mode.请在两个浏览器中检查 pdf 是否处于查看模式。

Firefox browser火狐浏览器

在此处输入图片说明

Chrome browser Chrome 浏览器

在此处输入图片说明

After that please check that you're pdf file is accessible via URL.之后,请检查您是否可以通过 URL 访问 pdf 文件。

<html>
<body>
<iframe
    src="{{ url('storage/images/sample.pdf') }}"
    style="width:400px; height:500px;"
    frameborder="0"
></iframe>
<object data="{{ url('storage/images/sample.pdf') }}" type="application/pdf"   style="width:400px; height:500px;">
    <p>Alternative text - include a link <a href="{{ url('storage/images/sample.pdf') }}">to the PDF!</a></p>
</object>
<embed src= "{{ url('storage/images/sample.pdf') }}"   style="width:400px; height:500px;">
</body>
</html>

In case if you're not be able to access pdf via url, make sure you're path is correct in case of storage : make sure symlink is created.如果您无法通过 url 访问 pdf,请确保您的路径在存储时正确:确保创建符号链接。

I hope this helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM