From a15a81c74e18085d3c6c1d5c71a232f9fd2a7b98 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 25 Jul 2013 10:01:45 -0700 Subject: [PATCH] First version --- Setup-PDF.js-in-a-website-(Windows).mediawiki | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Setup-PDF.js-in-a-website-(Windows).mediawiki diff --git a/Setup-PDF.js-in-a-website-(Windows).mediawiki b/Setup-PDF.js-in-a-website-(Windows).mediawiki new file mode 100644 index 0000000..82542d0 --- /dev/null +++ b/Setup-PDF.js-in-a-website-(Windows).mediawiki @@ -0,0 +1,89 @@ +== Setup the testing environment == + +The easiest way to setup your testing environment is to follow the instructions posted [https://github.com/mozilla/pdf.js/wiki/Setting-up-pdf.js-Development-Environment-for-Windows here]. You'll need Git, the Mozilla build environment and Node.js if you choose the recommended MSYS environment. After that, execute the following commands in Git Bash: + + cd / + git clone git://github.com/mozilla/pdf.js.git pdfjs + +=== Start the test server === + + cd ./pdfjs/ + node make server + +If Node.js complains about not recognizing python2.7 as an intenal or external command ([https://github.com/mozilla/pdf.js/issues/2016#issuecomment-8008140 more information here]), then go to your Python installation directory (in my case, C:\Python27), copy the file python.exe and rename the copy to python2.7.exe. After that, run the command again. + +Then you can reach your Node.js server using the following URL: + + http://localhost:8888/web/viewer.html + +You can test your own documents by placing them into the test directory and using an URL such as: + + http://localhost:8888/test/your-test-file.pdf + + +DRAFT FROM HERE + + +=== Opening PDF files from your website === + +You need to use the {{attr|file}} parameter in the URL whose value is a full [https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI encoded URI]. For example: + + http://mozilla.github.com/pdf.js/web/viewer.html?file=http%3A%2F%2Fasync5.org%2Fmoz%2Fpdfjs.pdf + +== Compile PDF.js == + +=== Build === +You need to run this command: + + node make generic + +and you should get the following output (or something similar): + + ### Getting extension build number + Extension build number: 331 + + ### Bundling files into build/pdf.js + + ### Building localization files + + ### Creating generic viewer + +=== Compressing PDF.js (unsupported!) === + +'''Minification is NOT supported''' by the developers of the project. First start testing with the full build and then use the minified version. From my test, the '''minified version did NOT''' work while the normal version did. + +You can minify PDF.js by approximately 30% with [http://yui.github.com/yuicompressor yui-compressor] or other [http://stackoverflow.com/questions/28932/best-javascript-compressor minification tools]. + +==== yui-compressor Ubuntu ==== + +There is a package for yui-compressor on Ubuntu 12.10 or Linux Mint 14: + + sudo apt-get install yui-compressor + cd + mkdir ./production/ + # yui-compressor ./build/pdf.js -o ./production/pdf-min.js # BEWARE OF UNSUPPORTED BEHAVIOR + +==== Use the minified file ==== + +'''Minification might break the libs''' using yui-compressor. Use at your own risk. + +Be sure to edit viewer.html and viewer.js to use the correct file. In this case, we want to use the minified version: + + # viewer.html + + + # viewer.js + PDFJS.workerSrc = './pdf-min.js'; + +== From build to production == + +Now that your build is done, you can copy the viewer and its resources (core files) to your production directory and upload the contents of that directory to your web server: + + # make a production directory if you haven't done so already + mkdir ./production/ + # copy the viewer and its resources to the production folder + cp -R ./build/generic ./production + +=== Compatibility === + +Note that you must include compatibility.js in order to support browsers like IE8+. \ No newline at end of file