Created
May 22, 2016 07:26
-
-
Save vinhlh/22c92f1a9f4fdb72fdbabefee34cef4d to your computer and use it in GitHub Desktop.
Setup PDF.js web viewer from its github repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# configs | |
JS_DIR=static/js/vendor/pdf.js | |
CSS_DIR=static/css/vendor/pdf.js | |
echo "[INFO] Clone https://github.com/mozilla/pdf.js into 'temp'" | |
git clone -b gh-pages https://github.com/mozilla/pdf.js temp | |
echo "[INFO] Init pdf.js directories" | |
rm -rf $JS_DIR | |
rm -rf $CSS_DIR | |
mkdir -p $JS_DIR | |
mkdir -p $CSS_DIR | |
echo "[INFO] Copy resource files to 'static' folder" | |
cp temp/web/viewer.css $CSS_DIR | |
cp -R temp/web/images $CSS_DIR | |
cp temp/web/compatibility.js $JS_DIR | |
cp temp/web/l10n.js $JS_DIR | |
cp temp/web/viewer.js $JS_DIR | |
cp temp/build/pdf.* $JS_DIR | |
cp -R temp/web $JS_DIR | |
cp -R temp/web/locale $JS_DIR | |
cp -R temp/web/cmaps $JS_DIR | |
echo "[INFO] Modify configs" | |
sed -i '' "s@../build/pdf.worker.js@static/js/vendor/pdf.js/pdf.worker.js@" $JS_DIR/viewer.js | |
sed -i '' "s@../web/cmaps/@static/js/vendor/pdf.js/cmaps@" $JS_DIR/viewer.js | |
sed -i '' "s@compressed.tracemonkey-pldi-09.pdf@@" $JS_DIR/viewer.js | |
echo "[INFO] Clear 'temp' directory" | |
rm -rf temp | |
echo "[INFO] Success" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create your viewer.html from https://github.com/mozilla/pdf.js/blob/gh-pages/web/viewer.html with new static resource's urls and your custom UI.