Skip to content

Commit

Permalink
Merge tag 'v2.0.943'
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacSchemm committed Nov 9, 2018
2 parents 7d9e51f + dc98bf7 commit 55e505e
Show file tree
Hide file tree
Showing 270 changed files with 16,693 additions and 7,976 deletions.
24 changes: 18 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 8,
"sourceType": "module",
},

"plugins": [
"mozilla"
"mozilla",
"unicorn",
],

"env": {
Expand All @@ -25,6 +26,7 @@
// Plugins
"mozilla/avoid-removeChild": "error",
"mozilla/use-includes-instead-of-indexOf": "error",
"unicorn/no-array-instanceof": "error",

// Possible errors
"for-direction": "error",
Expand Down Expand Up @@ -98,6 +100,20 @@
"no-catch-shadow": "error",
"no-delete-var": "error",
"no-label-var": "error",
"no-restricted-globals": ["error",
{
"name": "ReadableStream",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
{
"name": "URL",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
{
"name": "WritableStream",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
],
"no-shadow-restricted-names": "error",
"no-shadow": "off",
"no-undef-init": "error",
Expand Down Expand Up @@ -151,10 +167,6 @@
"space-infix-ops": ["error", { "int32Hint": false }],
"space-unary-ops": ["error", { "words": true, "nonwords": false, }],
"spaced-comment": ["error", "always", {
"line": {
"exceptions": ["//", "#else", "#endif"],
"markers": ["#if", "#elif", "#include", "#expand", "#error"],
},
"block": {
"balanced": true,
}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- node
- "10"
cache:
directories:
- node_modules
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ currently plan on supporting them in this fork.

For more information about pdf.js, see: https://github.com/mozilla/pdf.js

Until pdf.js 2.0 is released, all releases posted here will be based on pre-release versions of pdf.js.

## Getting the Code

To get a local copy of the current code, clone it using git:

$ git clone git://github.com/IsaacSchemm/pdf.js-seamonkey.git
$ cd pdf.js

Next, install Node.js via the [official package](http://nodejs.org) or via
Next, install Node.js via the [official package](https://nodejs.org) or via
[nvm](https://github.com/creationix/nvm). You need to install the gulp package
globally (see also [gulp's getting started](https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md#getting-started)):

Expand Down
2 changes: 1 addition & 1 deletion docs/contents/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/wintersmith-makerelative.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ module.exports = (env, callback) ->
depth = count(source, '/') # 1 being /
ret = ""
ret += "../" while depth = depth - 1
ret + dest.substr(1)
ret + dest.substring(1)

callback()
14 changes: 7 additions & 7 deletions examples/components/simpleviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ var container = document.getElementById('viewerContainer');
// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new pdfjsViewer.PDFLinkService();

// (Optionally) enable find controller.
var pdfFindController = new pdfjsViewer.PDFFindController({
linkService: pdfLinkService,
});

var pdfViewer = new pdfjsViewer.PDFViewer({
container: container,
linkService: pdfLinkService,
findController: pdfFindController,
});
pdfLinkService.setViewer(pdfViewer);

// (Optionally) enable find controller.
var pdfFindController = new pdfjsViewer.PDFFindController({
pdfViewer: pdfViewer,
});
pdfViewer.setFindController(pdfFindController);

container.addEventListener('pagesinit', function () {
// We can use pdfViewer now, e.g. let's change default scale.
pdfViewer.currentScaleValue = 'page-width';

if (SEARCH_FOR) { // We can try search for things
pdfFindController.executeCommand('find', {query: SEARCH_FOR});
pdfFindController.executeCommand('find', { query: SEARCH_FOR, });
}
});

Expand Down
14 changes: 7 additions & 7 deletions examples/components/singlepageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ var container = document.getElementById('viewerContainer');
// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new pdfjsViewer.PDFLinkService();

// (Optionally) enable find controller.
var pdfFindController = new pdfjsViewer.PDFFindController({
linkService: pdfLinkService,
});

var pdfSinglePageViewer = new pdfjsViewer.PDFSinglePageViewer({
container: container,
linkService: pdfLinkService,
findController: pdfFindController,
});
pdfLinkService.setViewer(pdfSinglePageViewer);

// (Optionally) enable find controller.
var pdfFindController = new pdfjsViewer.PDFFindController({
pdfViewer: pdfSinglePageViewer,
});
pdfSinglePageViewer.setFindController(pdfFindController);

container.addEventListener('pagesinit', function () {
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
pdfSinglePageViewer.currentScaleValue = 'page-width';

if (SEARCH_FOR) { // We can try search for things
pdfFindController.executeCommand('find', {query: SEARCH_FOR});
pdfFindController.executeCommand('find', { query: SEARCH_FOR, });
}
});

Expand Down
16 changes: 0 additions & 16 deletions examples/helloworld/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions examples/helloworld/hello.js

This file was deleted.

Binary file removed examples/helloworld/helloworld.pdf
Binary file not shown.
14 changes: 0 additions & 14 deletions examples/helloworld/index.html

This file was deleted.

Binary file added examples/image_decoders/fish.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions examples/image_decoders/jpeg_viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<!--
Copyright 2018 Mozilla Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html dir="ltr" mozdisallowselectionprint>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
<title>PDF.js standalone JpegImage parser</title>

<style>
body {
background-color: #808080;
margin: 0;
padding: 0;
}
</style>

<script src="../../node_modules/pdfjs-dist/image_decoders/pdf.image_decoders.js"></script>
</head>

<body tabindex="1">
<canvas id="jpegCanvas" width="0" height="0"></canvas>

<script src="jpeg_viewer.js"></script>
</body>
</html>
79 changes: 79 additions & 0 deletions examples/image_decoders/jpeg_viewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* Copyright 2018 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

if (!pdfjsImageDecoders.JpegImage) {
alert('Please build the pdfjs-dist library using `gulp dist-install`');
}

var JPEG_IMAGE = 'fish.jpg';

var jpegCanvas = document.getElementById('jpegCanvas');
var jpegCtx = jpegCanvas.getContext('2d');

// Load the image data, and convert it to a Uint8Array.
//
var nonBinaryRequest = false;
var request = new XMLHttpRequest();
request.open('GET', JPEG_IMAGE, false);
try {
request.responseType = 'arraybuffer';
nonBinaryRequest = request.responseType !== 'arraybuffer';
} catch (e) {
nonBinaryRequest = true;
}
if (nonBinaryRequest && request.overrideMimeType) {
request.overrideMimeType('text/plain; charset=x-user-defined');
}
request.send(null);

var typedArrayImage;
if (nonBinaryRequest) {
var str = request.responseText, length = str.length;
var bytes = new Uint8Array(length);
for (var i = 0; i < length; ++i) {
bytes[i] = str.charCodeAt(i) & 0xFF;
}
typedArrayImage = bytes;
} else {
typedArrayImage = new Uint8Array(request.response);
}

// Parse the image data using `JpegImage`.
//
var jpegImage = new pdfjsImageDecoders.JpegImage();
jpegImage.parse(typedArrayImage);

var width = jpegImage.width, height = jpegImage.height;
var jpegData = jpegImage.getData({
width,
height,
forceRGB: true,
});

// Render the JPEG image on a <canvas>.
//
var imageData = jpegCtx.createImageData(width, height);
var imageBytes = imageData.data;
for (var i = 0, j = 0, ii = width * height * 4; i < ii;) {
imageBytes[i++] = jpegData[j++];
imageBytes[i++] = jpegData[j++];
imageBytes[i++] = jpegData[j++];
imageBytes[i++] = 255;
}
jpegCanvas.width = width, jpegCanvas.height = height;
jpegCtx.putImageData(imageData, 0, 0);

2 changes: 1 addition & 1 deletion examples/mobile-viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Example to demonstrate PDF.js library usage with a viewer optimized for mobile u

## Getting started

Build PDF.js using `gulp dist` and run `gulp server` to start a web server.
Build PDF.js using `gulp dist-install` and run `gulp server` to start a web server.
You can then work with the mobile viewer at
http://localhost:8888/examples/mobile-viewer/viewer.html.

Expand Down
Loading

0 comments on commit 55e505e

Please sign in to comment.