diff --git a/README.md b/README.md index e49790b9e..a0261414b 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,7 @@ You can play with the PDF.js API directly from your browser using the live demos + [Interactive examples](http://mozilla.github.io/pdf.js/examples/index.html#interactive-examples) -The repository contains a hello world example that you can run locally: - -+ [examples/helloworld/](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/) - -More examples can be found in the examples folder. Some of them are using the pdfjs-dist package, which can be built and installed in this repo directory via `gulp dist-install` command. +More examples can be found in the [examples folder](https://github.com/mozilla/pdf.js/tree/master/examples/). Some of them are using the pdfjs-dist package, which can be built and installed in this repo directory via `gulp dist-install` command. For an introduction to the PDF.js code, check out the presentation by our contributor Julian Viereck: diff --git a/docs/contents/examples/index.md b/docs/contents/examples/index.md index 31e1b5763..4a58257b1 100644 --- a/docs/contents/examples/index.md +++ b/docs/contents/examples/index.md @@ -5,7 +5,7 @@ template: layout.jade ## Hello World Walkthrough -[Full source](https://github.com/mozilla/pdf.js/tree/master/examples/helloworld) +[Full source](https://github.com/mozilla/pdf.js/blob/master/examples/learning/helloworld.html) PDF.js heavily relies on the use of [Promises](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise). If promises are new to you, it's recommended you become familiar with them before continuing on. diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md deleted file mode 100644 index bc979fbb7..000000000 --- a/examples/helloworld/README.md +++ /dev/null @@ -1,16 +0,0 @@ -## Overview - -The "hello world" example is a minimalistic application of the PDF.js project. -The file `helloworld.pdf` originates from the GNUpdf project and contains a -simple and human-readable PDF. - -## Getting started - -Instead of simply opening `index.html` in a browser, you must serve the page -using a web server. This can be done on your local machine without an internet -connection. In the root directory of PDF.js, run `gulp server` in a -terminal. The example can then be viewed using the following URL: - -`http://localhost:8888/examples/helloworld/index.html` - -Take a look at `hello.js` to see how to make basic calls to PDF.js. diff --git a/examples/helloworld/hello.js b/examples/helloworld/hello.js deleted file mode 100644 index 08ce2ff29..000000000 --- a/examples/helloworld/hello.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -// In production, the bundled pdf.js shall be used instead of SystemJS. -Promise.all([System.import('pdfjs/display/api'), - System.import('pdfjs/display/worker_options'), - System.import('pdfjs/display/network'), - System.resolve('pdfjs/worker_loader')]) - .then(function (modules) { - var api = modules[0]; - var GlobalWorkerOptions = modules[1].GlobalWorkerOptions; - var network = modules[2]; - api.setPDFNetworkStreamFactory((params) => { - return new network.PDFNetworkStream(params); - }); - - // In production, change this to point to the built `pdf.worker.js` file. - GlobalWorkerOptions.workerSrc = modules[3]; - - // Fetch the PDF document from the URL using promises. - api.getDocument('helloworld.pdf').then(function (pdf) { - // Fetch the page. - pdf.getPage(1).then(function (page) { - var scale = 1.5; - var viewport = page.getViewport(scale); - - // Prepare canvas using PDF page dimensions. - var canvas = document.getElementById('the-canvas'); - var context = canvas.getContext('2d'); - canvas.height = viewport.height; - canvas.width = viewport.width; - - // Render PDF page into canvas context. - var renderContext = { - canvasContext: context, - viewport: viewport - }; - page.render(renderContext); - }); - }); -}); diff --git a/examples/helloworld/helloworld.pdf b/examples/helloworld/helloworld.pdf deleted file mode 100644 index d98b4e1db..000000000 --- a/examples/helloworld/helloworld.pdf +++ /dev/null @@ -1,68 +0,0 @@ -%PDF-1.7 - -1 0 obj % entry point -<< - /Type /Catalog - /Pages 2 0 R ->> -endobj - -2 0 obj -<< - /Type /Pages - /MediaBox [ 0 0 200 200 ] - /Count 1 - /Kids [ 3 0 R ] ->> -endobj - -3 0 obj -<< - /Type /Page - /Parent 2 0 R - /Resources << - /Font << - /F1 4 0 R - >> - >> - /Contents 5 0 R ->> -endobj - -4 0 obj -<< - /Type /Font - /Subtype /Type1 - /BaseFont /Times-Roman ->> -endobj - -5 0 obj % page content -<< - /Length 44 ->> -stream -BT -70 50 TD -/F1 12 Tf -(Hello, world!) Tj -ET -endstream -endobj - -xref -0 6 -0000000000 65535 f -0000000010 00000 n -0000000079 00000 n -0000000173 00000 n -0000000301 00000 n -0000000380 00000 n -trailer -<< - /Size 6 - /Root 1 0 R ->> -startxref -492 -%%EOF \ No newline at end of file diff --git a/examples/helloworld/index.html b/examples/helloworld/index.html deleted file mode 100644 index e27316eac..000000000 --- a/examples/helloworld/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - -
- - - - - - - - - - diff --git a/examples/svgviewer/index.html b/examples/svgviewer/index.html index 2b19c29f7..9c538f144 100644 --- a/examples/svgviewer/index.html +++ b/examples/svgviewer/index.html @@ -1,29 +1,51 @@ - + + - -