diff --git a/.gitignore b/.gitignore index bb045de3e..9b20a7778 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ *~ -pdf.pdf -intelisa.pdf -openweb_tm-PRINT.pdf local.mk build/ +tags diff --git a/Makefile b/Makefile index 2ce3aba6f..34a7930a3 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,12 @@ BUILD_DIR := build BUILD_TARGET := $(BUILD_DIR)/pdf.js DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json DEFAULT_TESTS := test_manifest.json +DEFAULT_PYTHON := python2.7 EXTENSION_SRC := ./extensions/ +EXTENSION_BASE_VERSION := 4bb289ec499013de66eb421737a4dbb4a9273eda FIREFOX_EXTENSION_NAME := pdf.js.xpi +FIREFOX_AMO_EXTENSION_NAME := pdf.js.amo.xpi CHROME_EXTENSION_NAME := pdf.js.crx all: bundle @@ -34,6 +37,7 @@ PDF_JS_FILES = \ stream.js \ worker.js \ ../external/jpgjs/jpg.js \ + jpx.js \ $(NULL) # make server @@ -41,8 +45,12 @@ PDF_JS_FILES = \ # This target starts a local web server at localhost:8888. This can be # used for testing all browsers. server: - @cd test; python test.py --port=8888; + @cd test; $(DEFAULT_PYTHON) test.py --port=8888; +# make test +# +# This target runs all the tests excluding the unit-test. This can be used for +# testing all browsers. test: shell-test browser-test # @@ -65,10 +73,17 @@ bundle: | $(BUILD_DIR) cat $(PDF_JS_FILES) > all_files.tmp; \ sed '/PDFJSSCRIPT_INCLUDE_ALL/ r all_files.tmp' pdf.js > ../$(BUILD_TARGET); \ sed -i.bak "s/PDFJSSCRIPT_BUNDLE_VER/`git log --format="%h" -n 1`/" ../$(BUILD_TARGET); \ - rm -f ../$(BUILD_TARGET).bak + rm -f ../$(BUILD_TARGET).bak; \ rm -f *.tmp; \ cd .. +# make unit-test +# +# This target runs in-browser unit tests with js-test-driver and jasmine unit +# test framework. +unit-test: + @cd test/unit/ ; make ; + # make browser-test # # This target runs in-browser tests using two primary arguments: a @@ -93,7 +108,7 @@ browser-test: fi; cd test; \ - python test.py --reftest \ + $(DEFAULT_PYTHON) test.py --reftest \ --browserManifestFile=$(PDF_BROWSERS) \ --manifestFile=$(PDF_TESTS) @@ -147,7 +162,10 @@ web: | production extension compiler pages-repo @cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET) @cp -R web/* $(GH_PAGES)/web @cp web/images/* $(GH_PAGES)/web/images - @cp $(EXTENSION_SRC)/firefox/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)/firefox/ + @cp $(FIREFOX_BUILD_DIR)/$(FIREFOX_EXTENSION_NAME) \ + $(FIREFOX_BUILD_DIR)/$(FIREFOX_AMO_EXTENSION_NAME) \ + $(FIREFOX_BUILD_DIR)/update.rdf \ + $(GH_PAGES)/$(EXTENSION_SRC)/firefox/ @cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html; @mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html; @cd $(GH_PAGES); git add -A; @@ -190,8 +208,7 @@ pages-repo: | $(BUILD_DIR) # This target produce a restartless firefox extension containing a # copy of the pdf.js source. CONTENT_DIR := content -FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/ -CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/ +BUILD_NUMBER := `git log --format=oneline $(EXTENSION_BASE_VERSION).. | wc -l | awk '{print $$1}'` PDF_WEB_FILES = \ web/images \ web/compatibility.js \ @@ -199,26 +216,66 @@ PDF_WEB_FILES = \ web/viewer.js \ web/viewer-production.html \ $(NULL) + +FIREFOX_BUILD_DIR := $(BUILD_DIR)/firefox +FIREFOX_BUILD_CONTENT := $(FIREFOX_BUILD_DIR)/$(CONTENT_DIR)/ +FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/ +FIREFOX_EXTENSION_FILES_TO_COPY = \ + *.js \ + *.rdf \ + chrome.manifest \ + components \ + $(NULL) +FIREFOX_EXTENSION_FILES = \ + content \ + *.js \ + install.rdf \ + chrome.manifest \ + components \ + content \ + $(NULL) + +CHROME_BUILD_DIR := $(BUILD_DIR)/chrome +CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/ +CHROME_BUILD_CONTENT := $(CHROME_BUILD_DIR)/$(CONTENT_DIR)/ +CHROME_EXTENSION_FILES = \ + extensions/chrome/*.json \ + extensions/chrome/*.html \ + $(NULL) extension: | production + # Clear out everything in the firefox extension build directory + @rm -Rf $(FIREFOX_BUILD_DIR) + @mkdir -p $(FIREFOX_BUILD_CONTENT) + @mkdir -p $(FIREFOX_BUILD_CONTENT)/$(BUILD_DIR) + @mkdir -p $(FIREFOX_BUILD_CONTENT)/web + @cd extensions/firefox; cp -r $(FIREFOX_EXTENSION_FILES_TO_COPY) ../../$(FIREFOX_BUILD_DIR)/ # Copy a standalone version of pdf.js inside the content directory - @rm -Rf $(FIREFOX_CONTENT_DIR) - @mkdir -p $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR) - @mkdir -p $(FIREFOX_CONTENT_DIR)/web - @cp $(BUILD_TARGET) $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR) - @cp -r $(PDF_WEB_FILES) $(FIREFOX_CONTENT_DIR)/web/ - @mv -f $(FIREFOX_CONTENT_DIR)/web/viewer-production.html $(FIREFOX_CONTENT_DIR)/web/viewer.html - + @cp $(BUILD_TARGET) $(FIREFOX_BUILD_CONTENT)/$(BUILD_DIR)/ + @cp -r $(PDF_WEB_FILES) $(FIREFOX_BUILD_CONTENT)/web/ + @mv -f $(FIREFOX_BUILD_CONTENT)/web/viewer-production.html $(FIREFOX_BUILD_CONTENT)/web/viewer.html + # Update the build version number + @sed -i.bak "s/PDFJSSCRIPT_BUILD/$(BUILD_NUMBER)/" $(FIREFOX_BUILD_DIR)/install.rdf + @sed -i.bak "s/PDFJSSCRIPT_BUILD/$(BUILD_NUMBER)/" $(FIREFOX_BUILD_DIR)/update.rdf + @rm -f $(FIREFOX_BUILD_DIR)/*.bak # Create the xpi - @cd $(EXTENSION_SRC)/firefox; zip -r $(FIREFOX_EXTENSION_NAME) * + @cd $(FIREFOX_BUILD_DIR); zip -r $(FIREFOX_EXTENSION_NAME) $(FIREFOX_EXTENSION_FILES) @echo "extension created: " $(FIREFOX_EXTENSION_NAME) + # Build the amo extension too (remove the updateUrl) + @sed -i.bak "/updateURL/d" $(FIREFOX_BUILD_DIR)/install.rdf + @rm -f $(FIREFOX_BUILD_DIR)/*.bak + @cd $(FIREFOX_BUILD_DIR); zip -r $(FIREFOX_AMO_EXTENSION_NAME) $(FIREFOX_EXTENSION_FILES) + @echo "AMO extension created: " $(FIREFOX_AMO_EXTENSION_NAME) - # Copy a standalone version of pdf.js inside the extension directory - @rm -Rf $(CHROME_CONTENT_DIR) - @mkdir -p $(CHROME_CONTENT_DIR)/$(BUILD_DIR) - @mkdir -p $(CHROME_CONTENT_DIR)/web - @cp $(BUILD_TARGET) $(CHROME_CONTENT_DIR)/$(BUILD_DIR) - @cp -r $(PDF_WEB_FILES) $(CHROME_CONTENT_DIR)/web/ - @mv -f $(CHROME_CONTENT_DIR)/web/viewer-production.html $(CHROME_CONTENT_DIR)/web/viewer.html + # Clear out everything in the chrome extension build directory + @rm -Rf $(CHROME_BUILD_DIR) + @mkdir -p $(CHROME_BUILD_CONTENT) + @mkdir -p $(CHROME_BUILD_CONTENT)/$(BUILD_DIR) + @mkdir -p $(CHROME_BUILD_CONTENT)/web + @cp -R $(CHROME_EXTENSION_FILES) $(CHROME_BUILD_DIR)/ + # Copy a standalone version of pdf.js inside the content directory + @cp $(BUILD_TARGET) $(CHROME_BUILD_CONTENT)/$(BUILD_DIR)/ + @cp -r $(PDF_WEB_FILES) $(CHROME_BUILD_CONTENT)/web/ + @mv -f $(CHROME_BUILD_CONTENT)/web/viewer-production.html $(CHROME_BUILD_CONTENT)/web/viewer.html # Create the crx #TODO diff --git a/README.md b/README.md index da70a4f57..f12fce934 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ -# pdf.js +# PDF.JS - - -## Overview pdf.js is an HTML5 technology experiment that explores building a faithful and efficient Portable Document Format (PDF) renderer without native code @@ -16,7 +13,7 @@ successful. -## Getting started +# Getting started ### Online demo @@ -29,11 +26,12 @@ using the pdf.js API. ### Extension -An up-to-date Firefox extension is also available: +A Firefox extension is also available: + http://mozilla.github.com/pdf.js/extensions/firefox/pdf.js.xpi -(The above link is updated upon every merge to our master branch). +Note that this extension is self-updating, and by default Firefox will auto-update extensions on a +daily basis (you can change this through the `extensions.update.interval` option in `about:config`). For an experimental Chrome extension, get the code as explained below and issue `make extension`. Then open Chrome with the flag `--enable-experimental-extension-apis`, go to `Tools > Extension` @@ -68,12 +66,12 @@ In order to bundle all `src/` files into a final `pdf.js`, issue: This will generate the file `build/pdf.js` that can be included in your final project. (WARNING: That's a large file! Consider minifying it). -## Learning +# Learning Here are some initial pointers to help contributors get off the ground. Additional resources are available in a separate section below. -#### Hello world +### Hello world For a "hello world" example, take a look at: @@ -82,7 +80,7 @@ For a "hello world" example, take a look at: This example illustrates the bare minimum ingredients for integrating pdf.js in a custom project. -#### Introductory video +### Introductory video Check out the presentation by our contributor Julian Viereck on the inner workings of PDF and pdf.js: @@ -92,7 +90,7 @@ workings of PDF and pdf.js: -## Contributing +# Contributing pdf.js is a community-driven project, so contributors are always welcome. Simply fork our repo and contribute away. Good starting places for picking @@ -122,7 +120,7 @@ You can add your name to it! :) -## Running the tests +# Running the tests pdf.js comes with browser-level regression tests that allow one to probe whether it's able to successfully parse PDFs, as well as compare its output @@ -148,7 +146,7 @@ images. The test type `load` simply tests whether the file loads without raising any errors. -## Running tests through our bot +### Running tests through our bot If you are a reviewer, you can use our remote bot to issue comprehensive tests against reference images before merging pull requests. @@ -158,7 +156,7 @@ See the bot repo for details: + https://github.com/mozilla/pdf.js-bot -## Additional resources +# Additional resources Gallery of user projects and modifications: @@ -188,7 +186,7 @@ Follow us on twitter: @pdfjs -## PDF-related resources +### PDF-related resources A really basic overview of PDF is described here: @@ -205,4 +203,3 @@ a "PDF Reference" from Adobe: Recommended chapters to read: "2. Overview", "3.4 File Structure", "4.1 Graphics Objects" that lists the PDF commands. - diff --git a/examples/acroforms/index.html b/examples/acroforms/index.html index 5fad4648a..8a9053f78 100644 --- a/examples/acroforms/index.html +++ b/examples/acroforms/index.html @@ -23,6 +23,7 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/web/compatibility.js b/web/compatibility.js index e4e2f2440..26405ad8f 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -5,11 +5,16 @@ // Checking if the typed arrays are supported (function checkTypedArrayCompatibility() { - if (typeof Uint8Array !== 'undefined') + if (typeof Uint8Array !== 'undefined') { + // some mobile version might not support Float64Array + if (typeof Float64Array === 'undefined') + window.Float64Array = Float32Array; + return; + } function subarray(start, end) { - return this.slice(start, end); + return new TypedArray(this.slice(start, end)); } function setArrayOffset(array, offset) { @@ -46,6 +51,8 @@ window.Uint32Array = TypedArray; window.Int32Array = TypedArray; window.Uint16Array = TypedArray; + window.Float32Array = TypedArray; + window.Float64Array = TypedArray; })(); // Object.create() ? diff --git a/web/viewer.css b/web/viewer.css index a223868fd..409a113c7 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -15,6 +15,7 @@ body { /* === Toolbar === */ #controls { background-color: #eee; + background: -o-linear-gradient(bottom,#eee 0%,#fff 100%); background: -moz-linear-gradient(center bottom, #eee 0%, #fff 100%); background: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, #ddd), color-stop(1.0, #fff)); border-bottom: 1px solid #666; @@ -82,6 +83,7 @@ span#info { bottom: 18px; left: -290px; transition: left 0.25s ease-in-out 1s; + -o-transition: left 0.25s ease-in-out 1s; -moz-transition: left 0.25s ease-in-out 1s; -webkit-transition: left 0.25s ease-in-out 1s; z-index: 1; @@ -90,6 +92,7 @@ span#info { #sidebar:hover { left: 0px; transition: left 0.25s ease-in-out 0s; + -o-transition: left 0.25s ease-in-out 0s; -moz-transition: left 0.25s ease-in-out 0s; -webkit-transition: left 0.25s ease-in-out 0s; } @@ -365,7 +368,7 @@ canvas { color: black; padding: 3px; margin: 3px; - white-space: pre; + width: 98%; } .clearBoth { diff --git a/web/viewer.html b/web/viewer.html index 98c19a53c..09c7195ce 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -26,6 +26,7 @@ + @@ -67,10 +68,11 @@ - + +
@@ -113,7 +115,7 @@
- +