I am spending hours trying to figure out how to make this module work.
Everytime I click on the pdf document it open a windows window for download. How can i see the viewer?
please step by step documentation.

Comments

Did you follow the instructions that are on the main page of this mod?

Status:Active» Fixed

I copied the instruction from the module page to README.txt FTLOG.

:D

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Version:7.x-1.x-dev» 7.x-1.1
Category:support» task
Priority:Normal» Critical
Status:Closed (fixed)» Active

does not suffice

i've figured out to compile pdf.js in windows, which is a long and steep curve for newbies (not so bad in linux).
describing shortly...

REQUISITES FOR THE MODULE:
- node.js: binary or source
- pdf.js // download: source

REQUISITES FOR node.js (binary):
- Python interpreter: install package Python v2.7 in *nix, setup Python v2.7 for windows
- make: install package make in *nix, make is provided with node.js binary for windows

REQUISITES FOR node.js (source):
- Python interpreter: install package Python v2.7 in *nix, setup Python v2.7 for windows
- C++ compiler: install package g++ in *nix, setup MinGW (includes G++) OR CygWin (add G++) for windows
- make: install package make in *nix, make is provided with MinGw, add make to CygWin for windows

REQUISITES FOR pdf.js (source):
- Python interpreter: install package Python v2.7 in *nix, setup Python v2.7 for windows

INSTRUCTIONS (binary node.js, windows):
- download and install Python 2.7 (msi/setup)
- add Python directory to your %PATH%
- copy Python.exe to Python2.7.exe (node.js will look for this non-existing file)
- download and install node.js (binary)
- download and extract pdf.js archive
- navigate to pdf.js directory on the command line and execute: node make generic
- upload the contents of pdf.js-master/build to /sites/all/libraries/pdf.js
- enable module
- add File field (file or media widget)
- file widget: configure field display to PDF in full/default view
OR
- media widget: configure field display to Rendered file: default in full/default views, and add PDF display to the File type Application -> default view

then sadly, watch and see it not function for no file is given as argument to pdf.js...

INSTRUCTIONS (source/binary node.js, debian/apt *nix):
- open terminal and execute:
apt-get install python
(might require 2.7 instead of 2.5 or 2.6)
- follow node.js make/install instructions here
- execute in the terminal:

wget https://github.com/mozilla/pdf.js/archive/master.tar.gz
tar  -zxvf master.tar.gz
cd pdf.js-master
node make generic

OR
git clone git://github.com/mozilla/pdf.js.git pdfjs
cd pdfjs
node make generic

drupal steps are identical

or download pdf.js from here
and place it on /sites/all/libraries/pdf.js

installing node.js and npm on debian 6.0 (squeeze):
- add testing and unstable repos to debian as described here for example (add priorities), as node.js and npm aren't included in stable nor updates
- add node.js packages:
apt-get install libv8-dev/testing libssl-dev/testing libev-dev/testing libc-ares-dev/testing libc-ares2/testing nodejs/unstable npm/unstable

So does this thing even work anymore?

README http://drupalcode.org/project/pdf.git/blob/refs/heads/7.x-1.x:/README.txt

If you use "PDF default" display rather than "PDF first page", you don't need to compile pdf.js.

Yes I have read that and spent hours on it...No matter what I do it does not work, even if I use the pre-compiled version.
With the pre-compiled the pdf does not show up, all I get is a box with arrows for next page and re size the doc. It looks like it wants to show the pdf, but can only show it as a blank pdf. (If that makes any sense.)

Anything??

What I did, to make it work in Windows / Drupal 6 :

- Installed PDF module
- Downloaded ZIP from from https://github.com/mozilla/pdf.js , en put everything in /sites/all/libraries/pdf.js folder
- Downloaded Windows installer from http://nodejs.org/download/
- Added the install folder of nodejs, to my PATH variable, so I can call 'node' command from command line
- Through command line, browsed to /sites/all/libraries/pdf.js
- Typed 'node make generic'

I wanted to make the Full viewer work, so I started debugging that

The Full viewer is called through file/pdf_viewer/%node, and the menu callback for that URL, is pdf_js_viewer function.
That function however, gets the file like this :

$file = $node->field_filefield[0];

My field wasn't called 'field_filefield' however, so I replaced that with my field name.

The pdf_js_viewer function, in turn calls the theme function 'pdf_viewer', which resolves into the template pdf-viewer.tpl.php, located in the PDF module folder.
In that template file, theres a JS block :

      kDefaultURL = '<?php print $file_url; ?>';//overwriting kDefaultURL value and inserting our desired file URL...
      var file_node_id = '<?php print $nid; ?>';//variable used in notes js
      var lang = '<?php print $language->language; ?>';

However, I had to replace 'kDefaultURL = .. ' in that JS block, to 'DEFAULT_URL = .. '.

After that, when I browsed to file/pdf_viewer/[node_id] , I succesfully saw the PDF.

Thanks for the info. I'm using linux so I'm trying to apply what you wrote.

Should 'node make generic' have any output? When I do it, there is not out out, no hang or anything... its just like hitting enter.

And if I use the pre-built pdf.js all I get is a frame for a PDF. Just a white page, it has all the buttons for the PDf, but no content/pdf.

Status:Active» Closed (fixed)

For people who ask help for Drupal 6, please create new issues with the right version.
By the way, NadimBak is the author of the Drupal 6 version.

I'm using D7... So what would cause a empty PDF?

Well Got it working.

My steps

I'm using lubuntu with D7
I downloaded the module and placed it in the usual place. drupal/sites/all/modules

sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

npm did not install and I didnt' have the Amateur Packet Radio installed so I didnt need to do the symlink or uninstall it.

git clone git://github.com/mozilla/pdf.js.git pdfjs
cd pdfjs
node make generic

Where I was running into the problem was when I did git, I followed the directions for the directory pdfjs. So git made the directory pdfjs and not pdf.js, so once I renamed the directory it worked.

So for those who tried to help thanks!

My steps for getting this module to work on a Debian Squeeze - for Drupal 7. It took a while to figure out and some wrong turns were made so there might be an error in these steps.

OK - So what's going on? I'm not sure - but here's my rough take on it.

The server needs to have something called node.js installed. What is this? It is a Javascript engine. I'm not sure how it is used by this module.

This is not available as a package for Debian Squeeze. So, it has to be installed.

It can be installed from source directly on to the server with the old ./configure, make, make install stuff - but I would suggest a slightly different method. Compile it to a Debian package and then install the package. That way - I figure - it will be easier to remove if there are any issues.

Install node.js

First we need some tools.

# apt-get install python-software-properties python g++ make checkinstall

Now we will download node.js and build the deb to install. It doesn't matter where we download it to - it just needs somewhere to compile.

$ mkdir ~/src && cd $_
$ wget -N http://nodejs.org/dist/node-latest.tar.gz
$ tar xzvf node-latest.tar.gz && cd node-v*
$ ./configure

So, we've downloaded the latest node.js, unzipped it and run configure in the unzipped directory.

The following command needs to be run as root. Not sure if this is completely correct - but it worked for me.

# cd directory-to-node-just-downloaded
# checkinstall

When the script asks questions answer as best you can - I went with the defaults.

This looks like it then compiles the required deb file and installs it. You can check that the package is installed with:

# dpkg -l node*

Install the module

Download and enable the Drupal module pdf.

Install pdf.js

OK - So now we pull down the pdf.js library. The module then uses this library - and I think this library needs to use the node.js engine.

$ mkdir sites/all/libraries
$ git clone https://github.com/mozilla/pdf.js

This then seems to work. It looks like we should run

$ node make generic

but currently the module is working - so I'm leaving it where it is for now.

Use the module

OK. Go to a content type, add a field of type file.

Make sure you add the file extension 'pdf' to the allowed file types. After you've added the field click on the 'Manage Display' and select the format 'PDF default'.

Add a node and upload a PDF - this should then show up in a box when the node is viewed.

One problem - we apparently can't get the PDF to view correctly in IE9 on Windows 7. Apparently, I might have to actually compile the PDF.js - and there are notes referring to compatibility.js - but I don't know how to install it yet.

OK - so it's looking good.

Works on Chrome, Firefox on Ubuntu and looks OK on an S4 and a Nexus 10 and an iPad.

But - I've heard reported that it only loads the second page on IE9 on WIndows 7.

So, I've cd'd into sites/all/libraries/pdf.js and run

$ node make generic

but IE9 is still not happy.

On the site for PDF.js - https://github.com/mozilla/pdf.js/ it mentions:

Also, if you would like to support more browsers than firefox you'll also need to include compatibility.js from build/generic/web/

I'm not sure how this works - and whether or not the compatibility.js has been included when I ran 'node make generic'.

OK - an update.

IE9 on Windows 7 is OK. It was just one particular PDF which didn't render the first page - maybe because it was a page with a large graphic in it.

I've tested with a 39 page PDF which was a sort of Powerpoint looking brochire type thing and it has all rendered fine.

As a further update.

I've just moved the site to another server - so moved from a squeeze server to a wheezy one.

So, I've moved the database and all the files - including the libraries directory. And the PDF field is working even though I've not installed node on the new server.

So, I'm going to guess that the only reason to compile and install the 'node' package is to be able to run 'node make generic' to compile the the library which has been downloaded.