08 April 2021

How to integrate PDF.JS with Code Igniter

By default, fullscreen option is not available in the default pdf viewers of browser. I was looking for a plugin that provides a fullscreen option for pdf embedded inside an iframe. I was able to accomplish it using PDF.JS plugin.


Integrating PDF.JS into Code Igniter is very easy. 
  1. Download the source files from https://sourceforge.net/projects/pdf-js.mirror/
  2. Extract and copy pdfjs-2.7.570-dist folder inside your Code Igniter's JS folder.
  3. Open your main JS file (where you include all the .js files) and use the 
    following line to include the new JS file
    <
    script src="<path_to_your_website(url)>/js/pdfjs-2.7.570-dist/build/pdf.js"></script>
  4. Now you can open pdf in your PHP using
    <iframe src='<path_to_your_website(url)
    >js/pdfjs-2.7.570-dist/web/viewer.html?file=<name of pdf file>'></iframe>

I Hope you find this information helpful.

No comments:

How to integrate PDF.JS with Code Igniter

By default, fullscreen option is not available in the default pdf viewers of browser. I was looking for a plugin that provides a fullscreen ...