diff --git a/examples/browserify/.gitignore b/examples/browserify/.gitignore deleted file mode 100644 index c2658d7d1..000000000 --- a/examples/browserify/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/examples/browserify/README.md b/examples/browserify/README.md deleted file mode 100644 index 22ddbdf38..000000000 --- a/examples/browserify/README.md +++ /dev/null @@ -1,26 +0,0 @@ -## Overview - -Example to demonstrate PDF.js library usage with Browserify. - -## Getting started - -Build project and install the example dependencies: - - $ gulp dist-install - $ cd examples/browserify - $ npm install - -To build Browserify bundles, run `gulp build`. If you are running -a web server, you can observe the build results at -http://localhost:8888/examples/browserify/index.html - -See main.js, worker.js and gulpfile.js files. Please notice that PDF.js -packaging requires packaging of the main application and PDF.js worker code, -and the `workerSrc` path shall be set to the latter file. The pdf.worker.js file -shall be excluded from the main bundle. - -Alternatives to the gulp commands (without compression) are: - - $ mkdir -p ../../build/browserify - $ node_modules/.bin/browserify main.js -u ./node_modules/pdfjs-dist/build/pdf.worker.js -o ../../build/browserify/main.bundle.js - $ node_modules/.bin/browserify worker.js -o ../../build/browserify/pdf.worker.bundle.js diff --git a/examples/browserify/gulpfile.js b/examples/browserify/gulpfile.js deleted file mode 100644 index 15661bbfd..000000000 --- a/examples/browserify/gulpfile.js +++ /dev/null @@ -1,40 +0,0 @@ -const gulp = require("gulp"); -const browserify = require("browserify"); -const streamify = require("gulp-streamify"); -const rename = require("gulp-rename"); -const uglify = require("gulp-uglify"); -const source = require("vinyl-source-stream"); - -const OUTPUT_PATH = "../../build/browserify"; -const TMP_FILE_PREFIX = "../../build/browserify_"; - -gulp.task("build-bundle", function () { - return browserify("main.js", { output: TMP_FILE_PREFIX + "main.tmp" }) - .ignore(require.resolve("pdfjs-dist/build/pdf.worker")) // Reducing size - .bundle() - .pipe(source(TMP_FILE_PREFIX + "main.tmp")) - .pipe(streamify(uglify())) - .pipe(rename("main.bundle.js")) - .pipe(gulp.dest(OUTPUT_PATH)); -}); - -gulp.task("build-worker", function () { - // We can create our own viewer (see worker.js) or use already defined one. - const workerSrc = require.resolve("pdfjs-dist/build/pdf.worker.entry"); - return browserify(workerSrc, { output: TMP_FILE_PREFIX + "worker.tmp" }) - .bundle() - .pipe(source(TMP_FILE_PREFIX + "worker.tmp")) - .pipe( - streamify( - uglify({ - compress: { - sequences: false, // Chrome has issue with the generated code if true - }, - }) - ) - ) - .pipe(rename("pdf.worker.bundle.js")) - .pipe(gulp.dest(OUTPUT_PATH)); -}); - -gulp.task("build", gulp.series("build-bundle", "build-worker")); diff --git a/examples/browserify/index.html b/examples/browserify/index.html deleted file mode 100644 index 8bd4644d6..000000000 --- a/examples/browserify/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - browserify example - - - - - - diff --git a/examples/browserify/main.js b/examples/browserify/main.js deleted file mode 100644 index f033660ef..000000000 --- a/examples/browserify/main.js +++ /dev/null @@ -1,35 +0,0 @@ -// Any copyright is dedicated to the Public Domain. -// http://creativecommons.org/licenses/publicdomain/ - -// Hello world example for browserify. - -const pdfjsLib = require("pdfjs-dist"); - -const pdfPath = "../learning/helloworld.pdf"; - -// Setting worker path to worker bundle. -pdfjsLib.GlobalWorkerOptions.workerSrc = - "../../build/browserify/pdf.worker.bundle.js"; - -// Loading a document. -const loadingTask = pdfjsLib.getDocument(pdfPath); -loadingTask.promise - .then(function (pdfDocument) { - // Request a first page - return pdfDocument.getPage(1).then(function (pdfPage) { - // Display page on the existing canvas with 100% scale. - const viewport = pdfPage.getViewport({ scale: 1.0 }); - const canvas = document.getElementById("theCanvas"); - canvas.width = viewport.width; - canvas.height = viewport.height; - const ctx = canvas.getContext("2d"); - const renderTask = pdfPage.render({ - canvasContext: ctx, - viewport, - }); - return renderTask.promise; - }); - }) - .catch(function (reason) { - console.error("Error: " + reason); - }); diff --git a/examples/browserify/package.json b/examples/browserify/package.json deleted file mode 100644 index 60ee4405c..000000000 --- a/examples/browserify/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "browserify-pdf.js-example", - "version": "0.1.0", - "devDependencies": { - "browserify": "^13.0.0", - "gulp": "^3.9.1", - "gulp-rename": "^1.2.2", - "gulp-streamify": "^1.0.2", - "gulp-uglify": "^1.5.3", - "pdfjs-dist": "../../node_modules/pdfjs-dist", - "vinyl-source-stream": "^1.1.0" - }, - "scripts": { - "build": "gulp build" - } -} diff --git a/examples/browserify/worker.js b/examples/browserify/worker.js deleted file mode 100644 index 3ae28b39f..000000000 --- a/examples/browserify/worker.js +++ /dev/null @@ -1,9 +0,0 @@ -// Any copyright is dedicated to the Public Domain. -// http://creativecommons.org/licenses/publicdomain/ - -// Hello world example for browserify: worker bundle. - -(typeof window !== "undefined" - ? window - : {} -).pdfjsWorker = require("pdfjs-dist/build/pdf.worker");