我已经设法使用下面的代码片段在浏览器中打开 pdf。我希望它在新的浏览器选项卡中打开,而不是在同一页面中打开。
我没有使用标签。这段代码调用了许多操作,最后它应该显示 pdf。它工作正常,但我希望它在新选项卡中打开。
这可能吗?如果可以,请向我解释如何操作。
我正在使用 Magento (EE 12.02) 应用程序及其在 php 5.3 上的应用程序。
$file = $pdf_file_path;
$filename = $file_name;
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
最佳答案
您不能根据该请求执行此操作。
但是您可以通过在 a 标签中添加 target="_blank"在新浏览器窗口中打开链接,然后浏览器通常会使用新标签。
关于php - 使用此 php 代码在新选项卡中打开 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12730581/