如何使用 php 将 PDF 文件嵌入到 iframe 中
how to embed PDF file into iframe using php
我的目录中有简单的 PDF 文件,我使用 fopen
打开 PDF 文件。当我尝试将它嵌入 html iframe
时,文件没有显示。我知道我可以将源指定为 iframe
属性,但我想使用 PHP.
<?php
$myfile = fopen("http://ipaddress/file.pdf", "r") or die("Unable to open file!");
fclose($myfile);
?>
<body>
<iframe src="<?php $myfile; ?>#toolbar=0&navpanes=0&scrollbar=0" width="1000" height="1000"></iframe>
</body>
这应该可以解决问题。
<body>
<iframe src="http://ipaddress/file.pdf" width="1000" height="1000"></iframe>
</body>
如果文件是本地的你可以放本地文件URL。但该文件将无法在 Internet 上访问。
例如:
file:///D:/WebDesign/HTML/test/file.pdf
我的目录中有简单的 PDF 文件,我使用 fopen
打开 PDF 文件。当我尝试将它嵌入 html iframe
时,文件没有显示。我知道我可以将源指定为 iframe
属性,但我想使用 PHP.
<?php
$myfile = fopen("http://ipaddress/file.pdf", "r") or die("Unable to open file!");
fclose($myfile);
?>
<body>
<iframe src="<?php $myfile; ?>#toolbar=0&navpanes=0&scrollbar=0" width="1000" height="1000"></iframe>
</body>
这应该可以解决问题。
<body>
<iframe src="http://ipaddress/file.pdf" width="1000" height="1000"></iframe>
</body>
如果文件是本地的你可以放本地文件URL。但该文件将无法在 Internet 上访问。 例如:
file:///D:/WebDesign/HTML/test/file.pdf