Skip to content

Commit

Permalink
Fix some broken PDFJs references
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Mar 8, 2019
1 parent 7fb3731 commit 8e31db5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions sandbox/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import annotations from './annotations';

const DOCUMENT_ID = 'PDFJSAnnotate.pdf';

PDFJS.workerSrc = '../shared/pdf.worker.js';
pdfjsViewer.workerSrc = '../shared/pdf.worker.js';

PDFJSAnnotate.StoreAdapter.getAnnotations = (documentId, pageNumber) => {
return new Promise((resolve, reject) => {
resolve(annotations);
});
};

PDFJS.getDocument(DOCUMENT_ID).then((pdf) => {
pdfjsViewer.getDocument(DOCUMENT_ID).then((pdf) => {
Promise.all([
pdf.getPage(1),
PDFJSAnnotate.getAnnotations(1)
])
.then(([page, annotations]) => {
]).then(([page, annotations]) => {
data.page = page;
data.annotations = annotations;
render();
Expand All @@ -38,7 +37,7 @@ function render() {
let canvas = document.getElementById('canvas');
let svg = document.getElementById('svg');
let canvasContext = canvas.getContext('2d');

canvas.height = viewport.height;
canvas.width = viewport.width;
canvas.style.marginTop = ((viewport.height / 2) * -1) + 'px';
Expand Down
11 changes: 5 additions & 6 deletions web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const documentId = 'example.pdf';
const userId = 'testUser';
let PAGE_HEIGHT;
let RENDER_OPTIONS = {
documentId,
userId: 'testUser',
documentId: documentId,
userId: userId,
pdfDocument: null,
scale: parseFloat(localStorage.getItem(`${documentId}/scale`), 10) || 1.33,
rotate: parseInt(localStorage.getItem(`${documentId}/rotate`), 10) || 0
Expand Down Expand Up @@ -46,7 +46,6 @@ function render() {

let viewer = document.getElementById('viewer');
viewer.innerHTML = '';
console.log(pdf);
NUM_PAGES = pdf.numPages;
for (let i = 0; i < NUM_PAGES; i++) {
let page = UI.createPage(i + 1);
Expand All @@ -62,7 +61,7 @@ function render() {
render();

// Hotspot color stuff
(function () {
(function() {
let hotspotColor = localStorage.getItem(`${RENDER_OPTIONS.documentId}/hotspot/color`) || 'darkgoldenrod';
let currentTarget = undefined;

Expand Down Expand Up @@ -90,7 +89,7 @@ render();
}
}

initColorPicker(document.querySelector('.hotspot-color'), hotspotColor, function (value) {
initColorPicker(document.querySelector('.hotspot-color'), hotspotColor, function(value) {
if (value === hotspotColor) {
return; // nothing to do
}
Expand Down Expand Up @@ -126,7 +125,7 @@ render();
})();

// Text stuff
(function () {
(function() {
let textSize;
let textColor;

Expand Down

0 comments on commit 8e31db5

Please sign in to comment.