Job/Tip

php 에서 pdf 뷰어 기능 구현

하늘치 2013. 7. 16. 14:00
반응형



1. 구글에서 지원해주는 것을 이용한다..

 

 <iframe src="http://docs.google.com/gview?url=http://funroo.gipsys.co.kr/module/pdf/jubo_130519.pdf&embedded=true" style="width:718px; height:700px;" frameborder="0"></iframe>


 


 

2. php 자체 기능을 이용해서 iframe으로 뿌려준다.

viewer.php


    <?php
    $file = './jubo_130519.pdf';
    $filename = 'jubo.pdf'; /* Note: Always use .pdf at the end. */

    header('Content-type: application/pdf');
    header('Content-Disposition: inline; filename="'.$filename . '"');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($file));
    header('Accept-Ranges: bytes');

    @readfile($file);
    ?>

 

<iframe src="./viewer.php" style="width:718px; height:900px;" frameborder="0"></iframe>



반응형