PDF是由Adobe Systems用于与应用程序、操作系统、硬件无关的方式进行文件交换所发展出的文件格式。PDF文件以PostScript语言图象模型为基础,无论在哪种打印机上都可保证精确的颜色和准确的打印效果,即PDF会忠实地再现原稿的每一个字符、颜色以及图象。下面通过PHP来实现在线阅读PDF格式文件。
PHP实现在线读取并显示PDF文件内容,具体代码如下:
<?php if(!function_exists('read_pdf')) { function read_pdf($file) { if(strtolower(substr(strrchr($file,'.'),1)) != 'pdf') { echo '文件格式不对。'; return; } if(!file_exists($file)) { echo '文件不存在!'; return; } header('Content-type: application/pdf'); header('filename='.$file); readfile($file); } } read_pdf('yoodb_study.pdf');