Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo and add more documentation to gh-pages. #4585

Merged
merged 1 commit into from
Apr 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"locals": {
"url": "http://localhost:8080",
"name": "PDF.js Documentation",
"description": ""
},
"require": {
"moment": "moment",
"_": "underscore",
"typogr": "typogr"
},
"jade": {
"pretty": true
},
"markdown": {
"smartLists": true,
"smartypants": true
},
"plugins": [
"./plugins/wintersmith-makerelative.coffee"
]
}
8 changes: 8 additions & 0 deletions docs/contents/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: API
template: layout.jade
---

# API

We're currently working on better API docs, but the API is well documented in [api.js](https://github.com/mozilla/pdf.js/blob/master/src/display/api.js).
7 changes: 7 additions & 0 deletions docs/contents/css/bootstrap.min.css

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions docs/contents/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
body {
}
.starter-template {
padding: 0 15px;
}
.navbar-brand {
padding: 4px 15px;
}
.navbar-brand img {
height: 42px;
}
.navbar {
border-color: #e5e7e8;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
background-color: #fff;
border: 1px solid #e5e7e8;
border-width: 0 1px;
position: relative;
top: 1px;
}

footer {
padding-top: 40px;
padding-bottom: 40px;
margin-top: 100px;
color: #777;
text-align: center;
border-top: 1px solid #E5E5E5;
}

/* code styling */

code {
font-family: 'Anonymous Pro', monospace;
font-size: 0.85em;
color: #000;
}

pre code {
display: block;
line-height: 1.1;
}

p code {
padding: 0.1em 0.3em 0.2em;
border-radius: 0.3em;
position: relative;
top: -0.15em;
background: #444;
color: #fff;
white-space: nowrap;
}

/* syntax hl stuff */

code.lang-markdown {
color: #424242;
}

code.lang-markdown .header,
code.lang-markdown .strong {
font-weight: bold;
}

code.lang-markdown .emphasis {
font-style: italic;
}

code.lang-markdown .horizontal_rule,
code.lang-markdown .link_label,
code.lang-markdown .code,
code.lang-markdown .header,
code.lang-markdown .link_url {
color: #555;
}

code.lang-markdown .blockquote,
code.lang-markdown .bullet {
color: #bbb;
}

/* Tomorrow Theme */
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
.tomorrow-comment, pre .comment, pre .title {
color: #8e908c;
}

.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo {
color: #c82829;
}

.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant {
color: #f5871f;
}

.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute {
color: #eab700;
}

.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata {
color: #718c00;
}

.tomorrow-aqua, pre .css .hexcolor {
color: #3e999f;
}

.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title {
color: #4271ae;
}

.tomorrow-purple, pre .keyword, pre .javascript .function {
color: #8959a8;
}
65 changes: 65 additions & 0 deletions docs/contents/examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Examples
template: layout.jade
---

## Hello World Walkthrough

[Full source](https://github.com/mozilla/pdf.js/tree/master/examples/helloworld)

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.

### Document

The object structure of PDF.js loosely follows the structure of an actual PDF. At the top level there is a document object. From the document, more information and individual pages can be fetched. To get the document:

```js
PDFJS.getDocument('helloworld.pdf')
```

Remember though that PDF.js uses promises, so the above will return a promise that is resolved with the document object.

```js
PDFJS.getDocument('helloworld.pdf').then(function(pdf)) {
// you can now use *pdf* here
});
```

### Page
Now that we have the document, we can get a page. Again, this uses promises.

```js
pdf.getPage(1).then(function(page) {
// you can now use *page* here
});
```

### Rendering the Page
Each PDF page has its own viewport which defines the size in pixels(72DPI) and initial rotation. By default the viewport is scaled to the original size of the PDF, but this can be changed by modifying the viewport. When the viewport is created an initial transformation matrix will also be created that takes into account the desired scale, rotation, and it transforms the coordinate system (the 0,0 point in PDF documents the bottom-left whereas canvas 0,0 is top-left).

```js
var scale = 1.5;
var viewport = page.getViewport(scale);

var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;

var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
```

Alternatively, if you want the canvas to render to a certain pixel size you could do the following:

```js
var desiredWidth = 100;
var viewport = page.getViewport(1);
var scale = desiredWidth / viewport.width;
var scaledViewport = page.getViewport(scale);
```


114 changes: 114 additions & 0 deletions docs/contents/getting_started/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: Getting Started
template: layout.jade
---

# Getting Started

An introduction to PDF.js with examples.

## Introduction

Before downloading PDF.js please take a moment to understand the different layers of the PDF.js project.

<table class="table">
<thead>
<tr>
<th>Layer</th>
<th>About</th>
</tr>
</thead>
<tbody>
<tr>
<td>Core</td>
<td>The core layer is where a binary PDF is parsed and interpreted. This layer is the foundation for all subsequent layers. It is not documented here because using it directly is considered an advanced usage and the API is likely to change. For an example of using the core layer see the [PDF Object Browser](https://github.com/brendandahl/pdf.js.utils/tree/master/browser)
</td>
</tr>
<tr>
<td>Display</td>
<td>The display layer takes the core layer and exposes an easier to use API to render PDFs and get other information out of a document. This API is what the version number is based on.</td>
</tr>
<tr>
<td>Viewer</td>
<td>The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. *However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it.*</td>
</tr>
</tbody>
</table>

## Download

<div class="row">
<div class="col-md-6">
<h3>Pre-built</h3>
<p>
Includes the generic build of PDF.js and the viewer.
</p>
<span class="btn-group-vertical centered">
<a type="button" class="btn btn-primary" href="https://github.com/mozilla/pdf.js/releases/download/vSTABLE_VERSION/pdfjs-STABLE_VERSION-dist.zip">Stable (vSTABLE_VERSION)</a>
<a type="button" class="btn btn-warning" href="https://github.com/mozilla/pdf.js/releases/download/vBETA_VERSION/pdfjs-BETA_VERSION-dist.zip">Beta (vBETA_VERSION)</a>
</span>
</div>
<div class="col-md-6">
<h3>Source</h3>
To get a local copy of the current code, clone it using git:
<pre><code>$ git clone git://github.com/mozilla/pdf.js.git pdfjs
$ cd pdfjs
</code></pre>
</div>
</div>

## File Layout Overview

### Prebuilt

```
├── LICENSE
├── build/
│   ├── pdf.js - display layer
│   └── pdf.worker.js - core layer
└── web/
├── cmaps/ - character maps(required by core)
├── compatibility.js - polyfills for missing features
├── compressed.tracemonkey-pldi-09.pdf - test pdf
├── debugger.js - helpful pdf debugging features
├── images/ - images for the viewer and annotation icons
├── l10n.js - localization
├── locale/ - translation files
├── viewer.css - viewer style sheet
├── viewer.html - viewer html
└── viewer.js - viewer layer
```

### Source

```
├── AUTHORS
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── build/ - output of build steps (empty)
├── docs/ - this
├── examples/ - bare bones examples
├── extensions/ - various browser extensions
├── external/ - third party code
├── l10n/ - translation files
├── make.js - build script
├── package.json
├── src/
│   ├── core/ - core layer
│   ├── display/ - display layer
│   ├── images/
│   ├── pdf.js - wrapper file that everything is bundled into
│   ├── shared/ - shared code between core and display layers
│   └── worker_loader.js - used for developer builds to load worker files
├── test/ - reference, unit, and font tests
└── web/ - viewer layer
```

## Trying the Viewer

With the prebuilt or source version open `web/viewer.html` in a browser and the test pdf should load. Note: the worker is not enabled for file:// urls, so use a server. If you're using the source build and have node, you can run `node make server`.

## More Information

For a further walkthrough of a minimal viewer see the [hello world example](/examples/). More documentation can be found in our [wiki](https://github.com/mozilla/pdf.js/wiki) too.
Binary file added docs/contents/images/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions docs/contents/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/contents/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: PDF.js
template: layout.jade
---


<h1 class="text-center">PDF.js</h1>
<p class="text-center" style="font-size: 20px">A general-purpose, web standards-based platform for parsing and rendering PDFs.
</p>
<p class="text-center">
<a type="button" class="btn btn-lg btn-default" href="getting_started/#download">Download</a>
<a type="button" class="btn btn-lg btn-default" href="web/viewer.html">Demo</a>
<a type="button" class="btn btn-lg btn-default" href="https://github.com/mozilla/pdf.js">Github Project</a>
</p>
6 changes: 6 additions & 0 deletions docs/contents/js/bootstrap.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/contents/js/jquery-2.1.0.min.js

Large diffs are not rendered by default.

Loading