我的目录中有简单的 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。但该文件将无法通过互联网访问。 例如:
file:///D:/WebDesign/HTML/test/file.pdf
关于javascript - 如何使用php将PDF文件嵌入到iframe中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44272094/