2017-07-05 52 views
1

我想从/ var/www/pdf /目录中将pdf文件嵌入到我的网站中。我在/var/www/html/portal/index.php上托管了我的网页。我尝试以下使用利用的iframe将PDF文件嵌入到/ var/www/pdf /目录的html中

<iframe src="../../pdf/ebook.pdf" width="900" height="750" frameborder="0" allowfullscreen></iframe> 

3)对象它们的

<object data="../../pdf/ebook.pdf#scrollbar=0&toolbar=0&navpanes=0" width="900" height="750" type="application/pdf"> 
    <p>PDF cannot be displayed</p> 
</object> 

无工作使用嵌入

2)的方式

1),但如果我放置PDF文件/ var/www/html/pdf /文件夹它工作正常。

对于我的要求,我无法将文件保存在网络目录中,因为公共可以直接使用URL访问PDF文件,而无需登录到我的门户网站。而且也是谷歌可以索引我的PDF文件从公共搜索

请帮我嵌入PDF

在此先感谢

+0

您正在使用哪种网络服务器? – jgmh

+0

谢谢你的回复。 Web服务器 - Apache和服务器操作系统 - CentOS 7 – user231410

+0

你的目录'/ var/www/pdf /'在apache conf中是否需要权限? – jgmh

回答

0

你可以做到这一点.htaccess

第一:防止直接访问打开PDF文件

Refer this questions and answers

二:防止搜索引擎索引

Refere this

希望它会工作。我试图在评论中提供这些信息,但它在那里没有正确显示。

0

我找到解决方案使用PHP脚本

header("Content-type: application/pdf"); 
header("Content-Disposition: inline; filename=filename.pdf"); 
@readfile('../../pdf/ebook.pdf');