php - 如何在浏览器中从我的数据库中显示 PDF 文件?
问题描述
我想使用 HTML 的嵌入标签在浏览器中显示来自数据库的 PDF 文件。我怎样才能做到这一点?这是我的 PHP 代码:
$content_query="select * from time_table where semester_no=$current_semester";
$apply_query=sqlsrv_query($conn,$content_query);
$result_content = sqlsrv_fetch_array($apply_query);
$file_directory=$result_content['file_path'];
$exists=file_exists($result_content['file_path']);
$ext=$result_content['name'];
echo $direc="../admin/pages/".$file_directory; exit;
$path=$direc.$file_directory;
解决方案
您可以简单地将其添加到您的 html 代码中(假设您的 pdf 存储在可公开访问的路径中)
<embed src="{{url_to_pdf}}" width="1920" height="1080"/>
或者您也可以选择使用它,
<embed src="https://drive.google.com/viewerng/viewer?embedded=true&url={{url_to_pdf}}" width="1920" height="1080">
推荐阅读
- multi-factor-authentication - Azure B2C 自定义策略 - 无法为尚未登录的现有用户设置手机 mfa,并且在 mfa 完成之前无法登录
- python - 如何在 scipy.signal 中制作低通滤波器?
- c# - 有没有办法禁用 CTRL + I,.NET UWP WebView 中的选项卡插入
- python - 使用 DataFrame 对特定网格数据进行排序和排列的更好方法
- swift - 在 Swift 中,我可以找出哪个初始化器用于实例化一个类吗?
- matplotlib - 在 jupyter notebook 中缩放 matplotlib 图的 Y 轴
- python - 如何使用 re 模块将特定链接标签更改为文本?
- alexa - Alexa ASR 中注释集的批量编辑不起作用
- html - Django-VSCode-从静态文件加载的css“粘住”并且不响应编辑
- playframework - Lightbend 列出的示例项目之一不适用于较大的文件