--- /dev/null
+## "Hello World" overview
+
+This example is a minimalistic application of the pdf.js project. The file `helloworld.pdf` is from the GNUpdf project (see [Introduction to PDF at GNUpdf](http://gnupdf.org/Introduction_to_PDF), and contains a simple and human-readable PDF.
+
+
+## Getting started
+
+Point your browser to `index.html`. Voila. Take a peek at `hello.js` to see how to make basic calls to `pdf.js`.
+
+
+## Additional resources
+
++ [GNUpdf - Introduction to PDF](http://gnupdf.org/Introduction_to_PDF)
--- /dev/null
+//
+// See README for overview
+//
+
+
+//
+// Ajax GET request for binary files
+// (like jQuery's $.get(), but supports the binary type ArrayBuffer)
+//
+var binaryGet = function(url, callback){
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url);
+ xhr.mozResponseType = xhr.responseType = 'arraybuffer';
+ xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200;
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === 4 && xhr.status === xhr.expected) {
+ var data = (xhr.mozResponseArrayBuffer || xhr.mozResponse ||
+ xhr.responseArrayBuffer || xhr.response);
+
+ callback(data);
+ }
+ };
+ xhr.send(null);
+}
+
+//
+// This is where the fun happens
+//
+binaryGet('helloworld.pdf', function(data){
+ //
+ // Instantiate PDFDoc with PDF data
+ //
+ var pdf = new PDFDoc(new Stream(data));
+ var page = pdf.getPage(1);
+ var scale = 1.5;
+
+ //
+ // Prepare canvas using PDF page dimensions
+ //
+ var canvas = document.getElementById('the-canvas');
+ var context = canvas.getContext('2d');
+ canvas.height = page.height * scale;
+ canvas.width = page.width * scale;
+
+ //
+ // Render PDF page into canvas context
+ //
+ page.startRendering(context);
+});
--- /dev/null
+<!doctype html>
+<html>
+
+<head>
+ <!-- PDF.js-specific -->
+ <script type="text/javascript" src="../pdf.js"></script>
+ <script type="text/javascript" src="../metrics.js"></script>
+ <script type="text/javascript" src="../fonts.js"></script>
+ <script type="text/javascript" src="../glyphlist.js"></script>
+
+ <script type="text/javascript" src="hello.js"></script>
+</head>
+
+<body>
+ <canvas id="the-canvas" style="border:1px solid black;"/>
+</body>
+
+</html>