[英]How to open a pdf file in new tab from controller PHP (laravel)
Hi I am new to php programming. 嗨,我是php编程的新手。 I am using laravel 5.2 now.
我现在正在使用laravel 5.2。
I have used an external service to create a pdf from my html page. 我已使用外部服务从html页面创建pdf。 For that I have used pdfcrowd.
为此,我使用了pdfcrowd。 I wrote the content to a pdf file in my local system.
我将内容写到本地系统中的pdf文件中。 Its location is
/var/www/html/testproject/test_pdf.pdf
. 它的位置是
/var/www/html/testproject/test_pdf.pdf
。
It works fine. 工作正常。 Now my requirement is that, I have to open that pdf file in a new tab from my controller.
现在我的要求是,我必须从控制器的新选项卡中打开该pdf文件。 My controller name is adminController.
我的控制器名称是adminController。 Inside that I used a function to open the pdf.
在其中,我使用了一个函数来打开pdf。
Please see the code below: 请参见下面的代码:
public function open_pdf() {
$file_location='/var/www/html/testproject/test_pdf.pdf';
----------?
}
Please suggest your ideas. 请提出您的想法。
The important thing to understand is that, we can't open a new tab from php controller. 要了解的重要一点是,我们无法从php控制器中打开新标签页。 So In the view page (testpage.blade.php) I used 'target="_blank" code in a tag.
因此,在视图页面(testpage.blade.php)中,我在标记中使用了“ target =“ _ blank”代码。 please see the code below:
<a href="{{ url('/') }}/testproject/openpdf"> target="_blank"
请参见下面的代码:
<a href="{{ url('/') }}/testproject/openpdf"> target="_blank"
Try to add target="_blank"
in your html tags it will work fine. 尝试在您的html标记中添加
target="_blank"
,它将正常工作。 You may have use like this 你可能有这样的用途
<a href="{{ url('/') }}/testproject/openpdf">
please try with this 请尝试这个
<a href="{{ url('/') }}/testproject/openpdf" target="_blank">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.