Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2016 07:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Setup PDF.js web viewer from its github repository
# configs
echo "[INFO] Clone into 'temp'"
git clone -b gh-pages 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"
Copy link

vinhlh commented May 22, 2016

Create your viewer.html from with new static resource's urls and your custom UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment