- files_reader v1.1, now supports PDF, see CHANGELOG.md and README.md
for change information
BIN
files_reader/vendor/pdfjs/controllers/.bookmarks_controller.js.swp
vendored
Normal file
59
files_reader/vendor/pdfjs/controllers/annotationlayer_controller.js
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
PDFJS.Reader.AnnotationLayerController = function (options, reader) {
|
||||
|
||||
this.reader = reader;
|
||||
this.annotationDiv = options.annotationDiv;
|
||||
this.pdfPage = options.pdfPage;
|
||||
this.renderInteractiveForms = options.renderInteractiveForms;
|
||||
this.linkService = options.linkService;
|
||||
this.downloadManager = options.downloadManager;
|
||||
|
||||
this.div = null;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
PDFJS.Reader.AnnotationLayerController.prototype.render = function (viewport, intent) {
|
||||
var self = this;
|
||||
var parameters = {
|
||||
intent: (intent === undefined ? 'display' : intent),
|
||||
};
|
||||
|
||||
this.pdfPage.getAnnotations(parameters).then(function (annotations) {
|
||||
viewport = viewport.clone({ dontFlip: true });
|
||||
parameters = {
|
||||
viewport: viewport,
|
||||
div: self.div,
|
||||
annotations: annotations,
|
||||
page: self.pdfPage,
|
||||
renderInteractiveForms: self.renderInteractiveForms,
|
||||
linkService: self.linkService,
|
||||
downloadManager: self.downloadManager,
|
||||
};
|
||||
|
||||
if (self.div) {
|
||||
// If an annotationLayer already exists, refresh its children's
|
||||
// transformation matrices.
|
||||
PDFJS.AnnotationLayer.update(parameters);
|
||||
} else {
|
||||
// Create an annotation layer div and render the annotations
|
||||
// if there is at least one annotation.
|
||||
if (annotations.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.div = self.annotationDiv;
|
||||
parameters.div = self.div;
|
||||
|
||||
PDFJS.AnnotationLayer.render(parameters);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.AnnotationLayerController.prototype.hide = function () {
|
||||
|
||||
if (!this.div) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.div.setAttribute('hidden', 'true');
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
PDFJS.reader.BookmarksController = function() {
|
||||
|
||||
var reader = this,
|
||||
eventBus = this.eventBus,
|
||||
book = this.book,
|
||||
annotations = reader.settings.annotations;
|
||||
|
||||
|
@ -18,38 +19,68 @@ PDFJS.reader.BookmarksController = function() {
|
|||
|
||||
var addBookmarkItem = function (bookmark) {
|
||||
$list.append(reader.NotesController.createItem(bookmark));
|
||||
reader.settings.session.setBookmark(bookmark.id, bookmark.anchor, bookmark.type, bookmark);
|
||||
};
|
||||
|
||||
var addBookmark = function (pageNum) {
|
||||
var bookmark = new reader.Annotation(
|
||||
"bookmark",
|
||||
pageNum,
|
||||
null,
|
||||
pageToId(pageNum)
|
||||
);
|
||||
|
||||
addBookmarkItem(bookmark);
|
||||
};
|
||||
|
||||
var removeBookmark = function (pageNum) {
|
||||
var id = pageToId(pageNum);
|
||||
console.log("ID", id);
|
||||
|
||||
if (isBookmarked(id)) {
|
||||
delete reader.settings.annotations[id];
|
||||
reader.settings.session.deleteBookmark(id);
|
||||
if (id === pageToId(reader.settings.currentPage)) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
eventBus.on('bookmarkremoved', function removeBookmark1(e) {
|
||||
var id = e.id,
|
||||
$item = $("#"+id);
|
||||
|
||||
$item.remove();
|
||||
|
||||
if (id === pageToId(reader.settings.currentPage)) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
});
|
||||
|
||||
var pageToId = function (pageNum) {
|
||||
return "page_" + pageNum;
|
||||
};
|
||||
|
||||
var isBookmarked = function (pageNum) {
|
||||
return (reader.settings.annotations[pageToId(pageNum)] !== undefined);
|
||||
};
|
||||
|
||||
for (var bookmark in annotations) {
|
||||
if (annotations.hasOwnProperty(bookmark) && (annotations[bookmark].type === "bookmark"))
|
||||
addBookmarkItem(annotations[bookmark]);
|
||||
};
|
||||
|
||||
this.on("reader:bookmarkcreated", function (bookmark) {
|
||||
addBookmarkItem(bookmark);
|
||||
});
|
||||
|
||||
this.on("reader:bookmarkremoved", function (id) {
|
||||
var $item = $("#"+id),
|
||||
cfi = reader.book.getCurrentLocationCfi(),
|
||||
cfi_id = reader.cfiToId(cfi);
|
||||
|
||||
$item.remove();
|
||||
|
||||
if(cfi_id === id) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
});
|
||||
|
||||
this.on("reader:gotobookmark", function (bookmark) {
|
||||
if (bookmark && bookmark.value)
|
||||
book.gotoCfi(bookmark.value);
|
||||
});
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide
|
||||
"hide" : hide,
|
||||
"addItem" : addBookmarkItem,
|
||||
"addBookmark" : addBookmark,
|
||||
"removeBookmark" : removeBookmark,
|
||||
"pageToId" : pageToId,
|
||||
"isBookmarked" : isBookmarked
|
||||
};
|
||||
};
|
||||
|
|
|
@ -121,15 +121,16 @@ PDFJS.reader.ControlsController = function(book) {
|
|||
});
|
||||
|
||||
$bookmark.on("click", function() {
|
||||
var cfi = reader.book.getCurrentLocationCfi();
|
||||
var currentPage = reader.settings.currentPage,
|
||||
bmc = reader.BookmarksController;
|
||||
|
||||
if(!(reader.isBookmarked(cfi))) { //-- Add bookmark
|
||||
reader.addBookmark(cfi);
|
||||
if(!bmc.isBookmarked(currentPage)) { //-- Add bookmark
|
||||
bmc.addBookmark(currentPage);
|
||||
$bookmark
|
||||
.addClass("icon-turned_in")
|
||||
.removeClass("icon-turned_in_not");
|
||||
} else { //-- Remove Bookmark
|
||||
reader.removeBookmark(cfi);
|
||||
bmc.removeBookmark(currentPage);
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
PDFJS.reader.NotesController = function() {
|
||||
PDFJS.reader.NotesController = function(book) {
|
||||
|
||||
var book = this.book,
|
||||
reader = this,
|
||||
|
@ -9,10 +9,10 @@ PDFJS.reader.NotesController = function() {
|
|||
$next = $("#next"),
|
||||
$prev = $("#prev"),
|
||||
$touch_nav = $("#touch_nav"),
|
||||
$viewer = $("#viewer"),
|
||||
annotations = reader.settings.annotations,
|
||||
renderer = book.renderer,
|
||||
popups = [],
|
||||
epubcfi = new PDFJS.EpubCFI();
|
||||
popups = [];
|
||||
|
||||
var show = function() {
|
||||
$notesView.addClass('open');
|
||||
|
@ -31,8 +31,8 @@ PDFJS.reader.NotesController = function() {
|
|||
var range,
|
||||
textNode,
|
||||
offset,
|
||||
doc = book.renderer.doc,
|
||||
cfi,
|
||||
doc = document,
|
||||
loc,
|
||||
annotation;
|
||||
|
||||
// standard
|
||||
|
@ -47,6 +47,9 @@ PDFJS.reader.NotesController = function() {
|
|||
offset = range.startOffset;
|
||||
}
|
||||
|
||||
console.log("textNode", textNode, "offset", offset);
|
||||
console.log(e);
|
||||
|
||||
if (textNode.nodeType !== 3) {
|
||||
for (var i=0; i < textNode.childNodes.length; i++) {
|
||||
if (textNode.childNodes[i].nodeType == 3) {
|
||||
|
@ -64,9 +67,9 @@ PDFJS.reader.NotesController = function() {
|
|||
offset += 1; // After the period
|
||||
}
|
||||
|
||||
cfi = epubcfi.generateCfiFromTextNode(textNode, offset, book.renderer.currentChapter.cfiBase);
|
||||
loc = "";
|
||||
|
||||
annotation = new reader.Annotation('annotation', cfi, $text.val());
|
||||
annotation = new reader.Annotation('annotation', loc, $text.val());
|
||||
|
||||
// save...
|
||||
reader.addAnnotation(annotation);
|
||||
|
@ -87,6 +90,16 @@ PDFJS.reader.NotesController = function() {
|
|||
|
||||
var addAnnotationItem = function(annotation) {
|
||||
$notes.append(createItem(annotation));
|
||||
reader.settings.session.setBookmark(annotation.id, annotation.anchor, annotation.type, annotation);
|
||||
};
|
||||
|
||||
var removeAnnotation = function (id) {
|
||||
|
||||
if (annotations[id] !== undefined) {
|
||||
deleteAnnotationItem(id);
|
||||
delete annotations[id];
|
||||
reader.settings.session.deleteBookmark(id);
|
||||
}
|
||||
};
|
||||
|
||||
var deleteAnnotationItem = function (id) {
|
||||
|
@ -133,24 +146,14 @@ PDFJS.reader.NotesController = function() {
|
|||
link.href = "#"+annotation.anchor;
|
||||
|
||||
link.onclick = function(){
|
||||
book.gotoCfi(annotation.anchor);
|
||||
reader.queuePage(annotation.anchor);
|
||||
return false;
|
||||
};
|
||||
|
||||
del.onclick = function() {
|
||||
var id = this.parentNode.parentNode.getAttribute("id");
|
||||
//var marker = book.renderer.doc.getElementById("note-" + id);
|
||||
// remove note from collection...
|
||||
//reader.removeAnnotation(id);
|
||||
// ... and remove the marker...
|
||||
//if (marker) {
|
||||
// marker.remove();
|
||||
// renumberMarkers();
|
||||
//}
|
||||
// ...and finally remove the HTML representation
|
||||
//this.parentNode.parentNode.remove();
|
||||
//renumberMarkers();
|
||||
reader.removeAnnotation(id);
|
||||
console.log("ID", id);
|
||||
removeAnnotation(id);
|
||||
};
|
||||
|
||||
save.onclick = function() {
|
||||
|
@ -241,7 +244,7 @@ PDFJS.reader.NotesController = function() {
|
|||
mark.innerHTML = findIndex(annotation.id) + "[Reader]";
|
||||
|
||||
marker.appendChild(mark);
|
||||
epubcfi.addMarker(annotation.anchor, doc, marker);
|
||||
// epubcfi.addMarker(annotation.anchor, doc, marker);
|
||||
|
||||
markerEvents(marker, annotation.body);
|
||||
renumberMarkers();
|
||||
|
@ -251,17 +254,17 @@ PDFJS.reader.NotesController = function() {
|
|||
for (var note in annotations) {
|
||||
if (annotations.hasOwnProperty(note)) {
|
||||
var chapter = renderer.currentChapter;
|
||||
var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
if(cfi.spinePos === chapter.spinePos) {
|
||||
try {
|
||||
var marker = book.renderer.doc.getElementById("note-" + annotations[note].id);
|
||||
if (marker !== undefined) {
|
||||
marker.innerHTML = findIndex(annotations[note].id) + "[Reader]";
|
||||
}
|
||||
} catch(e) {
|
||||
console.log("renumbering of markers failed", annotations[note].anchor);
|
||||
}
|
||||
}
|
||||
// var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
// if(cfi.spinePos === chapter.spinePos) {
|
||||
// try {
|
||||
// var marker = book.renderer.doc.getElementById("note-" + annotations[note].id);
|
||||
// if (marker !== undefined) {
|
||||
// marker.innerHTML = findIndex(annotations[note].id) + "[Reader]";
|
||||
// }
|
||||
// } catch(e) {
|
||||
// console.log("renumbering of markers failed", annotations[note].anchor);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -406,7 +409,7 @@ PDFJS.reader.NotesController = function() {
|
|||
$prev.addClass("restore_touch_nav");
|
||||
}
|
||||
// listen for selection
|
||||
book.on("renderer:click", insertAtPoint);
|
||||
$viewer.on("click", insertAtPoint);
|
||||
} else {
|
||||
$text.prop("disabled", false);
|
||||
$anchor.removeClass("icon-location_off");
|
||||
|
@ -416,7 +419,8 @@ PDFJS.reader.NotesController = function() {
|
|||
$prev.addClass("touch_nav");
|
||||
$next.addClass("touch_nav");
|
||||
}
|
||||
book.off("renderer:click", insertAtPoint);
|
||||
|
||||
$viewer.off("click", insertAtPoint);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -425,36 +429,11 @@ PDFJS.reader.NotesController = function() {
|
|||
addAnnotationItem(annotations[note]);
|
||||
};
|
||||
|
||||
this.on("reader:annotationcreated", function (note) {
|
||||
addAnnotationItem(note);
|
||||
});
|
||||
|
||||
this.on("reader:annotationremoved", function (id) {
|
||||
deleteAnnotationItem(id);
|
||||
});
|
||||
|
||||
// replace markers for annotations
|
||||
renderer.registerHook("beforeChapterDisplay", function(callback, renderer){
|
||||
var chapter = renderer.currentChapter;
|
||||
for (var note in annotations) {
|
||||
if (annotations.hasOwnProperty(note) && (annotations[note].type === "annotation")) {
|
||||
var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
if(cfi.spinePos === chapter.spinePos) {
|
||||
try {
|
||||
placeMarker(annotations[note]);
|
||||
} catch(e) {
|
||||
console.log("anchoring failed", annotations[note].anchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
callback();
|
||||
}, true);
|
||||
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide,
|
||||
"createItem": createItem
|
||||
"createItem": createItem,
|
||||
"addItem" : addAnnotationItem,
|
||||
"removeAnnotation" : removeAnnotation
|
||||
};
|
||||
};
|
||||
|
|
|
@ -464,6 +464,7 @@ PDFJS.reader.SearchController = function () {
|
|||
var root = document.getElementById("searchResults"),
|
||||
item,
|
||||
match,
|
||||
matchlist,
|
||||
i;
|
||||
|
||||
item = root.getElementsByClassName("selected");
|
||||
|
@ -472,12 +473,13 @@ PDFJS.reader.SearchController = function () {
|
|||
|
||||
match = document.getElementById("match:" + selected.pageIdx + ":" + selected.matchIdx);
|
||||
match.classList.add("selected");
|
||||
match = document.getElementsByClassName("match:" + selected.pageIdx + ":" + selected.matchIdx);
|
||||
for (i = 0; i < match.length; i++)
|
||||
match[i].classList.add("selected_again");
|
||||
|
||||
|
||||
updateMatchCounter(match.dataset.index);
|
||||
|
||||
//matchlist = document.getElementsByClassName("match:" + selected.pageIdx + ":" + selected.matchIdx);
|
||||
//for (i = 0; i < matchlist.length; i++)
|
||||
// matchlist[i].classList.add("selected_again");
|
||||
|
||||
if (!reader.isVisible(match))
|
||||
match.scrollIntoView();
|
||||
|
||||
|
|
153
files_reader/vendor/pdfjs/css/annotation_layer_builder.css
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* Copyright 2014 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.
|
||||
*/
|
||||
|
||||
.annotationLayer {
|
||||
position: absolute;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.annotationLayer section {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a {
|
||||
position: absolute;
|
||||
font-size: 1em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a /* -ms-a */ {
|
||||
background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") 0 0 repeat;
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a:hover {
|
||||
opacity: 0.2;
|
||||
background: #ff0;
|
||||
box-shadow: 0px 2px 10px #ff0;
|
||||
}
|
||||
|
||||
.annotationLayer .textAnnotation img {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input,
|
||||
.annotationLayer .textWidgetAnnotation textarea,
|
||||
.annotationLayer .choiceWidgetAnnotation select,
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input,
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input {
|
||||
background-color: rgba(0, 54, 255, 0.13);
|
||||
border: 1px solid transparent;
|
||||
box-sizing: border-box;
|
||||
font-size: 9px;
|
||||
height: 100%;
|
||||
padding: 0 3px;
|
||||
vertical-align: top;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation textarea {
|
||||
font: message-box;
|
||||
font-size: 9px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input[disabled],
|
||||
.annotationLayer .textWidgetAnnotation textarea[disabled],
|
||||
.annotationLayer .choiceWidgetAnnotation select[disabled],
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled] {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:hover,
|
||||
.annotationLayer .textWidgetAnnotation textarea:hover,
|
||||
.annotationLayer .choiceWidgetAnnotation select:hover,
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input:hover {
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:focus,
|
||||
.annotationLayer .textWidgetAnnotation textarea:focus,
|
||||
.annotationLayer .choiceWidgetAnnotation select:focus {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input.comb {
|
||||
font-family: monospace;
|
||||
padding-left: 2px;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input.comb:focus {
|
||||
/*
|
||||
* Letter spacing is placed on the right side of each character. Hence, the
|
||||
* letter spacing of the last character may be placed outside the visible
|
||||
* area, causing horizontal scrolling. We avoid this by extending the width
|
||||
* when the element has focus and revert this when it loses focus.
|
||||
*/
|
||||
width: 115%;
|
||||
}
|
||||
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input,
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
-ms-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.annotationLayer .popupWrapper {
|
||||
position: absolute;
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
.annotationLayer .popup {
|
||||
position: absolute;
|
||||
z-index: 200;
|
||||
max-width: 20em;
|
||||
background-color: #FFFF99;
|
||||
box-shadow: 0px 2px 5px #333;
|
||||
border-radius: 2px;
|
||||
padding: 0.6em;
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.annotationLayer .popup h1 {
|
||||
font-size: 1em;
|
||||
border-bottom: 1px solid #000000;
|
||||
padding-bottom: 0.2em;
|
||||
}
|
||||
|
||||
.annotationLayer .popup p {
|
||||
padding-top: 0.2em;
|
||||
}
|
||||
|
||||
.annotationLayer .highlightAnnotation,
|
||||
.annotationLayer .underlineAnnotation,
|
||||
.annotationLayer .squigglyAnnotation,
|
||||
.annotationLayer .strikeoutAnnotation,
|
||||
.annotationLayer .fileAttachmentAnnotation {
|
||||
cursor: pointer;
|
||||
}
|
11
files_reader/vendor/pdfjs/css/images/annotation-check.svg
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<path
|
||||
d="M 1.5006714,23.536225 6.8925879,18.994244 14.585721,26.037937 34.019683,4.5410479 38.499329,9.2235032 14.585721,35.458952 z"
|
||||
id="path4"
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#000000;stroke-width:1.25402856;stroke-opacity:1" />
|
||||
</svg>
|
After Width: | Height: | Size: 415 B |
16
files_reader/vendor/pdfjs/css/images/annotation-comment.svg
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
height="40"
|
||||
width="40"
|
||||
viewBox="0 0 40 40">
|
||||
<rect
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
width="33.76017"
|
||||
height="33.76017"
|
||||
x="3.119915"
|
||||
y="3.119915" />
|
||||
<path
|
||||
d="m 20.677967,8.54499 c -7.342801,0 -13.295293,4.954293 -13.295293,11.065751 0,2.088793 0.3647173,3.484376 1.575539,5.150563 L 6.0267418,31.45501 13.560595,29.011117 c 2.221262,1.387962 4.125932,1.665377 7.117372,1.665377 7.3428,0 13.295291,-4.954295 13.295291,-11.065753 0,-6.111458 -5.952491,-11.065751 -13.295291,-11.065751 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.93031836;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 883 B |
26
files_reader/vendor/pdfjs/css/images/annotation-help.svg
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<g
|
||||
transform="translate(0,-60)"
|
||||
id="layer1">
|
||||
<rect
|
||||
width="36.460953"
|
||||
height="34.805603"
|
||||
x="1.7695236"
|
||||
y="62.597198"
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.30826771;stroke-opacity:1" />
|
||||
<g
|
||||
transform="matrix(0.88763677,0,0,0.88763677,2.2472646,8.9890584)">
|
||||
<path
|
||||
d="M 20,64.526342 C 11.454135,64.526342 4.5263421,71.454135 4.5263421,80 4.5263421,88.545865 11.454135,95.473658 20,95.473658 28.545865,95.473658 35.473658,88.545865 35.473658,80 35.473658,71.454135 28.545865,64.526342 20,64.526342 z m -0.408738,9.488564 c 3.527079,0 6.393832,2.84061 6.393832,6.335441 0,3.494831 -2.866753,6.335441 -6.393832,6.335441 -3.527079,0 -6.393832,-2.84061 -6.393832,-6.335441 0,-3.494831 2.866753,-6.335441 6.393832,-6.335441 z"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.02768445;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
d="m 7.2335209,71.819938 4.9702591,4.161823 c -1.679956,2.581606 -1.443939,6.069592 0.159325,8.677725 l -5.1263071,3.424463 c 0.67516,1.231452 3.0166401,3.547686 4.2331971,4.194757 l 3.907728,-4.567277 c 2.541952,1.45975 5.730694,1.392161 8.438683,-0.12614 l 3.469517,6.108336 c 1.129779,-0.44367 4.742234,-3.449633 5.416358,-5.003859 l -5.46204,-4.415541 c 1.44319,-2.424098 1.651175,-5.267515 0.557303,-7.748623 l 5.903195,-3.833951 C 33.14257,71.704996 30.616217,69.018606 29.02952,67.99296 l -4.118813,4.981678 C 22.411934,71.205099 18.900853,70.937534 16.041319,72.32916 l -3.595408,-5.322091 c -1.345962,0.579488 -4.1293881,2.921233 -5.2123901,4.812869 z m 8.1010311,3.426672 c 2.75284,-2.446266 6.769149,-2.144694 9.048998,0.420874 2.279848,2.56557 2.113919,6.596919 -0.638924,9.043185 -2.752841,2.446267 -6.775754,2.13726 -9.055604,-0.428308 -2.279851,-2.565568 -2.107313,-6.589485 0.64553,-9.035751 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
10
files_reader/vendor/pdfjs/css/images/annotation-insert.svg
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64">
|
||||
<path
|
||||
d="M 32.003143,1.4044602 57.432701,62.632577 6.5672991,62.627924 z"
|
||||
style="fill:#ffff00;fill-opacity:0.94117647;fill-rule:nonzero;stroke:#000000;stroke-width:1.00493038;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</svg>
|
After Width: | Height: | Size: 408 B |
11
files_reader/vendor/pdfjs/css/images/annotation-key.svg
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64">
|
||||
<path
|
||||
d="M 25.470843,9.4933766 C 25.30219,12.141818 30.139101,14.445969 34.704831,13.529144 40.62635,12.541995 41.398833,7.3856498 35.97505,5.777863 31.400921,4.1549155 25.157674,6.5445892 25.470843,9.4933766 z M 4.5246282,17.652051 C 4.068249,11.832873 9.2742983,5.9270407 18.437379,3.0977088 29.751911,-0.87185184 45.495663,1.4008022 53.603953,7.1104009 c 9.275765,6.1889221 7.158128,16.2079421 -3.171076,21.5939521 -1.784316,1.635815 -6.380222,1.21421 -7.068351,3.186186 -1.04003,0.972427 -1.288046,2.050158 -1.232864,3.168203 1.015111,2.000108 -3.831548,1.633216 -3.270553,3.759574 0.589477,5.264544 -0.179276,10.53738 -0.362842,15.806257 -0.492006,2.184998 1.163456,4.574232 -0.734888,6.610642 -2.482919,2.325184 -7.30604,2.189143 -9.193497,-0.274767 -2.733688,-1.740626 -8.254447,-3.615254 -6.104247,-6.339626 3.468112,-1.708686 -2.116197,-3.449897 0.431242,-5.080274 5.058402,-1.39256 -2.393215,-2.304318 -0.146889,-4.334645 3.069198,-0.977415 2.056986,-2.518352 -0.219121,-3.540397 1.876567,-1.807151 1.484149,-4.868919 -2.565455,-5.942205 0.150866,-1.805474 2.905737,-4.136876 -1.679967,-5.20493 C 10.260902,27.882167 4.6872697,22.95045 4.5245945,17.652051 z"
|
||||
id="path604"
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#000000;stroke-width:1.72665179;stroke-opacity:1" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
11
files_reader/vendor/pdfjs/css/images/annotation-newparagraph.svg
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64">
|
||||
<path
|
||||
d="M 32.003143,10.913072 57.432701,53.086929 6.567299,53.083723 z"
|
||||
id="path2985"
|
||||
style="fill:#ffff00;fill-opacity:0.94117647;fill-rule:nonzero;stroke:#000000;stroke-width:0.83403099;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</svg>
|
After Width: | Height: | Size: 426 B |
7
files_reader/vendor/pdfjs/css/images/annotation-noicon.svg
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
</svg>
|
After Width: | Height: | Size: 158 B |
42
files_reader/vendor/pdfjs/css/images/annotation-note.svg
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<rect
|
||||
width="36.075428"
|
||||
height="31.096582"
|
||||
x="1.962286"
|
||||
y="4.4517088"
|
||||
id="rect4"
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.23004246;stroke-opacity:1" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="1.5012145"
|
||||
x="6.0157046"
|
||||
y="10.285"
|
||||
id="rect6"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="0.85783684"
|
||||
x="6.0157056"
|
||||
y="23.21689"
|
||||
id="rect8"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="0.85783684"
|
||||
x="5.8130345"
|
||||
y="28.964394"
|
||||
id="rect10"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="0.85783684"
|
||||
x="6.0157046"
|
||||
y="17.426493"
|
||||
id="rect12"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
</svg>
|
After Width: | Height: | Size: 1 KiB |
16
files_reader/vendor/pdfjs/css/images/annotation-paragraph.svg
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<rect
|
||||
width="33.76017"
|
||||
height="33.76017"
|
||||
x="3.119915"
|
||||
y="3.119915"
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
d="m 17.692678,34.50206 0,-16.182224 c -1.930515,-0.103225 -3.455824,-0.730383 -4.57593,-1.881473 -1.12011,-1.151067 -1.680164,-2.619596 -1.680164,-4.405591 0,-1.992435 0.621995,-3.5796849 1.865988,-4.7617553 1.243989,-1.1820288 3.06352,-1.7730536 5.458598,-1.7730764 l 9.802246,0 0,2.6789711 -2.229895,0 0,26.3251486 -2.632515,0 0,-26.3251486 -3.45324,0 0,26.3251486 z"
|
||||
style="font-size:29.42051125px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.07795751;stroke-opacity:1;font-family:Arial;-inkscape-font-specification:Arial" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
2
files_reader/vendor/pdfjs/css/sidebar.css
vendored
|
@ -62,7 +62,7 @@
|
|||
/* font-size: 1em; */
|
||||
padding: 0.4em 0.2em;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
/* height: 100%; */
|
||||
}
|
||||
|
||||
.mobile .sidebar div > button {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
/* overflow: hidden; */
|
||||
opacity: 0.2;
|
||||
line-height: 1.0;
|
||||
}
|
||||
|
|
387
files_reader/vendor/pdfjs/pdf.reader.js
vendored
|
@ -41,6 +41,8 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
canvasLimit: 0,
|
||||
cssZoomOnly: false, // true || false, only zoom using CSS, render document at 100% size
|
||||
textSelect: true, // true || false, add selectable text layer
|
||||
annotationLayer: true, // true || false. show PDF annotations
|
||||
mergeAnnotations: true,// true || false, merge PDF annotations into bookmarks/annotations
|
||||
doubleBuffer: true, // true || false, draw to off-screen canvas
|
||||
cacheNext: true, // true || false, pre-render next page (by creathing thumbnail))
|
||||
numPages: 0,
|
||||
|
@ -86,9 +88,26 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
annotations: {},
|
||||
customStyles: {},
|
||||
activeStyles: {},
|
||||
session: {}
|
||||
session: {
|
||||
getCursor: function() {},
|
||||
setCursor: function(value) {},
|
||||
getBookmark: function(name, type) {},
|
||||
setBookmark: function(name, value, type, content) {},
|
||||
getDefault: function(name) {},
|
||||
setDefault: function(name, value) {},
|
||||
getPreference: function(name) {},
|
||||
setPreference: function(name, value) {}
|
||||
}
|
||||
});
|
||||
|
||||
// event bus service
|
||||
var eventBus = new PDFJS.Reader.EventBus();
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// link service
|
||||
var linkService = new PDFJS.Reader.LinkService( { eventBus: this.eventBus }, reader);
|
||||
this.linkService = linkService;
|
||||
|
||||
// used for annotations and bookmarks
|
||||
this.Annotation = function (type, anchor, body, id) {
|
||||
this.id = id || PDFJS.core.uuid();
|
||||
|
@ -112,7 +131,9 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
canvas: document.getElementById("left"),
|
||||
ctx: document.getElementById("left").getContext('2d'),
|
||||
textdiv: document.getElementById("text_left"),
|
||||
annotationdiv: document.getElementById("annotations_left"),
|
||||
textLayer: null,
|
||||
annotationLayer: null,
|
||||
renderTask: null,
|
||||
oscanvas: null,
|
||||
osctx: null,
|
||||
|
@ -122,7 +143,9 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
canvas: document.getElementById("right"),
|
||||
ctx: document.getElementById("right").getContext('2d'),
|
||||
textdiv: document.getElementById("text_right"),
|
||||
annotationdiv: document.getElementById("annotations_right"),
|
||||
textLayer: null,
|
||||
annotationLayer: null,
|
||||
renderTask: null,
|
||||
oscanvas: null,
|
||||
osctx: null,
|
||||
|
@ -194,74 +217,127 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
reader.ProgressController.setProgress(progress);
|
||||
};
|
||||
|
||||
loadingTask.then(
|
||||
loadingTask.then(
|
||||
|
||||
function(_book) {
|
||||
reader.book = book = _book;
|
||||
//console.log(book);
|
||||
reader.settings.numPages = reader.book.numPages;
|
||||
document.getElementById('total_pages').textContent = reader.settings.numPages;
|
||||
if(!$.isEmptyObject(reader.settings.session.cursor)) {
|
||||
console.log("setting cursor:", reader.settings.session.cursor);
|
||||
reader.settings.currentPage = parseInt(reader.settings.session.cursor.anchor);
|
||||
function(_book) {
|
||||
reader.book = book = _book;
|
||||
//console.log(book);
|
||||
reader.settings.numPages = reader.book.numPages;
|
||||
document.getElementById('total_pages').textContent = reader.settings.numPages;
|
||||
console.log(reader.settings);
|
||||
console.log("numPages",reader.settings.numPages);
|
||||
console.log("cursor",reader.settings.session.cursor);
|
||||
if(!$.isEmptyObject(reader.settings.session.cursor)
|
||||
&& (reader.settings.session.cursor.value !== null)
|
||||
&& (reader.settings.session.cursor.value < reader.settings.numPages)) {
|
||||
console.log("setting cursor:", reader.settings.session.cursor);
|
||||
reader.settings.currentPage = parseInt(reader.settings.session.cursor.value);
|
||||
}
|
||||
|
||||
var firstPagePromise = book.getPage(1);
|
||||
reader.firstPagePromise = firstPagePromise;
|
||||
|
||||
reader.linkService.setDocument(book, location.href.split('#')[0]);
|
||||
|
||||
// set labels
|
||||
reader.book.getPageLabels().then(function (labels) {
|
||||
if (labels) {
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
if (labels[i] !== (i + 1).toString()) {
|
||||
reader.pageLabels[i + 1] = labels[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reader.ReaderController = PDFJS.reader.ReaderController.call(reader, book);
|
||||
reader.SettingsController = PDFJS.reader.SettingsController.call(reader, book);
|
||||
reader.ControlsController = PDFJS.reader.ControlsController.call(reader, book);
|
||||
reader.SidebarController = PDFJS.reader.SidebarController.call(reader, book);
|
||||
|
||||
reader.queuePage(reader.settings.currentPage);
|
||||
reader.ReaderController.hideLoader();
|
||||
reader.ProgressController.hide();
|
||||
|
||||
reader.book.getOutline().then(function (outline) {
|
||||
reader.OutlineController = PDFJS.reader.OutlineController.call(reader, outline);
|
||||
});
|
||||
reader.book.getMetadata().then(function (metadata) {
|
||||
console.log("metadata", metadata);
|
||||
reader.settings.pdfMetadata = metadata;
|
||||
});
|
||||
reader.book.getAttachments().then(function (attachments) {
|
||||
console.log("attachments", attachments);
|
||||
});
|
||||
|
||||
reader.book.getStats().then(function (stats) {
|
||||
console.log("stats", stats);
|
||||
});
|
||||
|
||||
// BookmarksController depends on NotesController so load NotesController first
|
||||
reader.NotesController = PDFJS.reader.NotesController.call(reader, book);
|
||||
reader.BookmarksController = PDFJS.reader.BookmarksController.call(reader, book);
|
||||
|
||||
if (reader.settings.mergeAnnotations) {
|
||||
reader.firstPagePromise.then(function() {
|
||||
var numPages = reader.settings.numPages;
|
||||
|
||||
function extractAnnotations(pageIndex) {
|
||||
reader.book.getPage(pageIndex).then(function(page) {
|
||||
page.getAnnotations().then(function(annotations) {
|
||||
if (annotations.length > 0) {
|
||||
for (var annotation in annotations) {
|
||||
if (annotations.hasOwnProperty(annotation) && !annotations[annotation].parentId) {
|
||||
var ann = annotations[annotation],
|
||||
type = (ann.contents && ann.contents !== "") ? "annotation" : "bookmark",
|
||||
item;
|
||||
|
||||
item = new reader.Annotation(
|
||||
type,
|
||||
pageIndex,
|
||||
ann.contents,
|
||||
ann.id || PDFJS.core.uuid()
|
||||
);
|
||||
console.log(ann);
|
||||
|
||||
if (type === "annotation") {
|
||||
reader.NotesController.addItem(item);
|
||||
} else {
|
||||
reader.BookmarksController.addItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if ((pageIndex + 1) <= reader.settings.numPages) {
|
||||
extractAnnotations(pageIndex + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
extractAnnotations(1);
|
||||
});
|
||||
}
|
||||
|
||||
var firstPagePromise = book.getPage(1);
|
||||
reader.firstPagePromise = firstPagePromise;
|
||||
reader.SearchController = PDFJS.reader.SearchController.call(reader, book);
|
||||
//reader.MetaController = PDFJS.reader.MetaController.call(reader, meta);
|
||||
reader.TocController = PDFJS.reader.TocController.call(reader, book);
|
||||
},
|
||||
function getDocumentError(exception) {
|
||||
var message = exception && exception.message;
|
||||
var errormsg = "An error occurred while loading the PDF";
|
||||
if (exception instanceof PDFJS.InvalidPDFException) {
|
||||
errormsg = "Invalid or corrupted PDF file";
|
||||
} else if (exception instanceof PDFJS.MissingPDFException) {
|
||||
errormsg = "Missing PDF file";
|
||||
} else if (exception instanceof PDFJS.UnexpectedResponseException) {
|
||||
errormsg = "Unexpected server response";
|
||||
}
|
||||
|
||||
// set labels
|
||||
reader.book.getPageLabels().then(function (labels) {
|
||||
if (labels) {
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
if (labels[i] !== (i + 1).toString()) {
|
||||
reader.pageLabels[i + 1] = labels[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reader.ReaderController = PDFJS.reader.ReaderController.call(reader, book);
|
||||
reader.SettingsController = PDFJS.reader.SettingsController.call(reader, book);
|
||||
reader.ControlsController = PDFJS.reader.ControlsController.call(reader, book);
|
||||
reader.SidebarController = PDFJS.reader.SidebarController.call(reader, book);
|
||||
|
||||
reader.queuePage(reader.settings.currentPage);
|
||||
reader.ReaderController.hideLoader();
|
||||
reader.ProgressController.hide();
|
||||
|
||||
reader.book.getOutline().then(function (outline) {
|
||||
reader.OutlineController = PDFJS.reader.OutlineController.call(reader, outline);
|
||||
});
|
||||
reader.book.getMetadata().then(function (metadata) {
|
||||
console.log("metadata", metadata);
|
||||
reader.settings.pdfMetadata = metadata;
|
||||
});
|
||||
reader.book.getAttachments().then(function (attachments) {
|
||||
console.log("attachments", attachments);
|
||||
});
|
||||
|
||||
// BookmarksController depends on NotesController so load NotesController first
|
||||
//reader.NotesController = PDFJS.reader.NotesController.call(reader, book);
|
||||
//reader.BookmarksController = PDFJS.reader.BookmarksController.call(reader, book);
|
||||
reader.SearchController = PDFJS.reader.SearchController.call(reader, book);
|
||||
//reader.MetaController = PDFJS.reader.MetaController.call(reader, meta);
|
||||
reader.TocController = PDFJS.reader.TocController.call(reader, book);
|
||||
},
|
||||
function getDocumentError(exception) {
|
||||
var message = exception && exception.message;
|
||||
var errormsg = "An error occurred while loading the PDF";
|
||||
if (exception instanceof PDFJS.InvalidPDFException) {
|
||||
errormsg = "Invalid or corrupted PDF file";
|
||||
} else if (exception instanceof PDFJS.MissingPDFException) {
|
||||
errormsg = "Missing PDF file";
|
||||
} else if (exception instanceof PDFJS.UnexpectedResponseException) {
|
||||
errormsg = "Unexpected server response";
|
||||
}
|
||||
|
||||
console.log("Reader: ", errormsg);
|
||||
reader.ProgressController.setMessage(errormsg, "download", "error");
|
||||
}
|
||||
);
|
||||
console.log("Reader: ", errormsg);
|
||||
reader.ProgressController.setMessage(errormsg, "download", "error");
|
||||
}
|
||||
);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -395,6 +471,10 @@ PDFJS.Reader.prototype.cancelRender = function (index) {
|
|||
resourcelst.textLayer.cancel();
|
||||
resourcelst.textLayer = null;
|
||||
}
|
||||
|
||||
if (resourcelst.annotationLayer) {
|
||||
resourcelst.annotationLayer = null;
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
||||
|
@ -408,6 +488,7 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
oscanvas, // off-screen canvas
|
||||
osctx, // off-screen context
|
||||
textdiv,
|
||||
annotationdiv,
|
||||
textLayer,
|
||||
outputscale,
|
||||
max_view_width,
|
||||
|
@ -431,15 +512,17 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
resourcelst,
|
||||
swap_orientation,
|
||||
double_buffer,
|
||||
cache_next;
|
||||
cache_next,
|
||||
pageShift;
|
||||
|
||||
max_view_width = window.innerWidth;
|
||||
max_view_height = window.innerHeight;
|
||||
|
||||
if (this.settings.zoomLevel === "spread") {
|
||||
|
||||
// show second canvas
|
||||
// show second canvas and textlayer
|
||||
reader.resourcelst[1].canvas.style.display = "block";
|
||||
reader.resourcelst[1].textdiv.style.display = "block";
|
||||
max_view_width /= 2;
|
||||
// select canvas and ctx based on pageNum, pageShift and oddPageRight
|
||||
pageShift = 2;
|
||||
|
@ -449,10 +532,15 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
} else {
|
||||
|
||||
index = 0;
|
||||
pageShift = 1;
|
||||
// hide second canvas
|
||||
reader.resourcelst[1].canvas.style.display = "none";
|
||||
// hide second text layer
|
||||
reader.resourcelst[1].textdiv.style.display = "none";
|
||||
// clear text layer
|
||||
reader.resourcelst[1].textdiv.innerHTML = "";
|
||||
// clear annotation layer
|
||||
reader.resourcelst[1].annotationdiv.innerHTML = "";
|
||||
// clear page number
|
||||
reader.resourcelst[1].pageNum = null;
|
||||
|
||||
|
@ -468,12 +556,14 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
canvas = resourcelst.canvas;
|
||||
ctx = resourcelst.ctx;
|
||||
textdiv = resourcelst.textdiv;
|
||||
annotationdiv = resourcelst.annotationdiv;
|
||||
outputscale = reader.getOutputScale(resourcelst.ctx);
|
||||
fraction = reader.approximateFraction(outputscale);
|
||||
double_buffer = reader.settings.doubleBuffer;
|
||||
cache_next = reader.settings.cacheNext;
|
||||
|
||||
textdiv.innerHTML = "";
|
||||
annotationdiv.innerHTML = "";
|
||||
|
||||
if (pageNum <= this.settings.numPages && pageNum >= 1) {
|
||||
|
||||
|
@ -487,12 +577,20 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
resourcelst.textLayer = null;
|
||||
}
|
||||
|
||||
if (resourcelst.annotationLayer) {
|
||||
//resourcelst.annotationLayer.hide();
|
||||
resourcelst.annotationLayer = null;
|
||||
}
|
||||
|
||||
resourcelst.pageNum = pageNum;
|
||||
|
||||
if (reader.cancelPage[pageNum])
|
||||
delete reader.cancelPage[pageNum];
|
||||
|
||||
this.book.getPage(pageNum).then(function(page) {
|
||||
page.getAnnotations().then(function (annotations) {
|
||||
console.log("annotations", annotations);
|
||||
});
|
||||
//console.log(page);
|
||||
page_rotation = page.rotate;
|
||||
rotation = (page_rotation + reader.settings.rotation) % 360;
|
||||
|
@ -576,9 +674,6 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
}
|
||||
}
|
||||
|
||||
//console.log("outputscale: " + outputscale);
|
||||
//console.log("canvas w x h: " + canvas.width + " x " + canvas.height);
|
||||
|
||||
transform = (outputscale === 1)
|
||||
? null
|
||||
: [outputscale, 0, 0, outputscale, 0, 0];
|
||||
|
@ -595,7 +690,7 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
/* textlayer */
|
||||
if (reader.settings.textSelect) {
|
||||
textdiv.style.width = reader.roundToDivide(viewport.width, fraction[1]) + 'px';
|
||||
textdiv.style.height = reader.roundToDivide(viewport.height, fraction[1]) + 'px';
|
||||
textdiv.style.height = 0;
|
||||
offset = $(canvas).offset();
|
||||
$(textdiv).offset({
|
||||
top: offset.top,
|
||||
|
@ -613,9 +708,29 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
} else {
|
||||
resourcelst.textLayer = textLayer = null;
|
||||
}
|
||||
|
||||
/* /textLayer */
|
||||
|
||||
/* annotationLayer */
|
||||
if (reader.settings.annotationLayer) {
|
||||
annotationdiv.style.width = reader.roundToDivide(viewport.width, fraction[1]) + 'px';
|
||||
//annotationdiv.style.height = reader.roundToDivide(viewport.height, fraction[1]) + 'px';
|
||||
annotationdiv.style.height = 0;
|
||||
offset = $(canvas).offset();
|
||||
$(annotationdiv).offset({
|
||||
top: offset.top,
|
||||
left: offset.left
|
||||
});
|
||||
resourcelst.annotationLayer = new PDFJS.Reader.AnnotationLayerController({
|
||||
annotationDiv: annotationdiv,
|
||||
pdfPage: page,
|
||||
renderInteractiveForms: false,
|
||||
linkService: reader.linkService,
|
||||
downloadManager: null
|
||||
}, reader);
|
||||
resourcelst.annotationLayer.render(viewport, 'display');
|
||||
}
|
||||
/* /annotationLayer */
|
||||
|
||||
if (double_buffer) {
|
||||
resourcelst.oscanvas = oscanvas = document.createElement("canvas");
|
||||
resourcelst.osctx = context = osctx = oscanvas.getContext('2d');
|
||||
|
@ -688,6 +803,7 @@ PDFJS.Reader.prototype.queuePage = function(page) {
|
|||
reader.settings.currentPage = page;
|
||||
|
||||
reader.ControlsController.setCurrentPage(page);
|
||||
reader.settings.session.setCursor(page);
|
||||
|
||||
if (typeof reader.renderQueue === 'number') {
|
||||
window.clearTimeout(reader.renderQueue);
|
||||
|
@ -843,104 +959,6 @@ PDFJS.Reader.prototype.getPageLabel = function (page) {
|
|||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.navigateTo = function (destination) {
|
||||
|
||||
var reader = this,
|
||||
destString = "",
|
||||
destinationPromise,
|
||||
goToDestination;
|
||||
|
||||
goToDestination = function (destRef) {
|
||||
|
||||
var pageNumber;
|
||||
|
||||
if (destRef instanceof Object) {
|
||||
|
||||
pageNumber = reader.cachedPageNum(destRef);
|
||||
} else if ((destRef | 0) === destRef) { // Integer
|
||||
pageNumber = destRef + 1;
|
||||
} else {
|
||||
console.error('PDFJS.Reader.navigateTo: "' + destRef
|
||||
+ '" is not a valid destination reference.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageNumber) {
|
||||
|
||||
if (pageNumber < 1 || pageNumber > reader.settings.numPages) {
|
||||
console.error('PDFJS.Reader.navigateTo: "' + pageNumber
|
||||
+ '" is a non-existent page number.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reader.queuePage(pageNumber);
|
||||
|
||||
} else {
|
||||
|
||||
reader.book.getPageIndex(destRef).then(function (pageIndex) {
|
||||
|
||||
reader.cachePageRef(pageIndex + 1, destRef);
|
||||
goToDestination(destRef);
|
||||
}).catch(function () {
|
||||
console.error('PDFJS.Reader.navigateTo: "' + destRef
|
||||
+ '" is not a valid page reference.');
|
||||
|
||||
return;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
destString = destination;
|
||||
destinationPromise = reader.book.getDestination(destination);
|
||||
|
||||
} else {
|
||||
|
||||
destinationPromise = Promise.resolve(destination);
|
||||
|
||||
}
|
||||
|
||||
destinationPromise.then(function (_destination) {
|
||||
|
||||
destination = _destination;
|
||||
|
||||
if (!(destination instanceof Array)) {
|
||||
|
||||
console.error('PDFJS.Reader.navigateTo: "' + destination
|
||||
+ '" is not a valid destination array.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
goToDestination(destination[0]);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.pageRefStr = function (pageRef) {
|
||||
|
||||
return pageRef.num + ' ' + pageRef.gen + ' R';
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.cachePageRef = function (pageNum, pageRef) {
|
||||
|
||||
var reader = this,
|
||||
refStr;
|
||||
|
||||
reader.pageRefs[reader.pageRefStr(pageRef)] = pageNum;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.cachedPageNum = function (pageRef) {
|
||||
|
||||
var reader = this;
|
||||
|
||||
return (reader.pageRefs[reader.pageRefStr(pageRef)])
|
||||
|| null;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.getPageTextContent = function (pageIndex) {
|
||||
|
||||
var reader = this,
|
||||
|
@ -953,28 +971,6 @@ PDFJS.Reader.prototype.getPageTextContent = function (pageIndex) {
|
|||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.getDestinationHash = function (destination) {
|
||||
|
||||
var url = location.href.split('#')[0],
|
||||
str;
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
url += "#"
|
||||
+ (parseInt(destination) === destination)
|
||||
? "nameddest="
|
||||
: ""
|
||||
+ escape(destination);
|
||||
|
||||
} else if (destination instanceof Array) {
|
||||
|
||||
url += "#"
|
||||
+ escape(JSON.stringify(destination));
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.setStyles = function (element, item) {
|
||||
|
||||
var styleStr = "";
|
||||
|
@ -996,6 +992,7 @@ PDFJS.Reader.prototype.setStyles = function (element, item) {
|
|||
PDFJS.Reader.prototype.bindLink = function (element, item) {
|
||||
|
||||
var reader = this,
|
||||
linkService = this.linkService,
|
||||
destination = item.dest;
|
||||
|
||||
if (item.url) {
|
||||
|
@ -1010,10 +1007,12 @@ PDFJS.Reader.prototype.bindLink = function (element, item) {
|
|||
return;
|
||||
} else {
|
||||
|
||||
element.href = reader.getDestinationHash(destination);
|
||||
//element.href = reader.getDestinationHash(destination);
|
||||
element.href = linkService.getDestinationHash(destination);
|
||||
element.onclick = function () {
|
||||
if (destination) {
|
||||
reader.navigateTo(destination);
|
||||
//reader._navigateTo(destination);
|
||||
linkService.navigateTo(destination);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
39
files_reader/vendor/pdfjs/services/eventbus_service.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
PDFJS.Reader.EventBus = function () {
|
||||
|
||||
this._listeners = Object.create(null);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
PDFJS.Reader.EventBus.prototype.on = function (eventName, listener) {
|
||||
var eventListeners = this._listeners[eventName];
|
||||
if (!eventListeners) {
|
||||
eventListeners = [];
|
||||
this._listeners[eventName] = eventListeners;
|
||||
}
|
||||
eventListeners.push(listener);
|
||||
};
|
||||
|
||||
PDFJS.Reader.EventBus.prototype.off = function (eventName, listener) {
|
||||
var eventListeners = this._listeners[eventName];
|
||||
var i;
|
||||
if (!eventListeners || ((i = eventListeners.indexOf(listener)) < 0)) {
|
||||
return;
|
||||
}
|
||||
eventListeners.splice(i, 1);
|
||||
};
|
||||
|
||||
PDFJS.Reader.EventBus.prototype.dispatch = function (eventName) {
|
||||
var eventListeners = this._listeners[eventName];
|
||||
if (!eventListeners || eventListeners.length === 0) {
|
||||
return;
|
||||
}
|
||||
// Passing all arguments after the eventName to the listeners.
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
// Making copy of the listeners array in case if it will be modified
|
||||
// during dispatch.
|
||||
eventListeners.slice(0).forEach(function (listener) {
|
||||
listener.apply(null, args);
|
||||
});
|
||||
};
|
||||
|
360
files_reader/vendor/pdfjs/services/link_service.js
vendored
Normal file
|
@ -0,0 +1,360 @@
|
|||
PDFJS.Reader.LinkService = function (options, reader) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
this.eventBus = options.eventBus || reader.eventBus;
|
||||
this.reader = reader;
|
||||
this.baseUrl = null;
|
||||
this.pdfDocument = null;
|
||||
this.pdfHistory = null;
|
||||
this.pageRefs = null;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Object.defineProperties(PDFJS.Reader.LinkService, {
|
||||
'pagesCount': {
|
||||
get: function () { return this.pdfDocument ? this.pdfDocument.numPages : 0; }
|
||||
},
|
||||
'page': {
|
||||
get: function () { return reader.settings.currentPage; },
|
||||
set: function(value) { reader.settings.currentPage = value; }
|
||||
}
|
||||
});
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.setDocument = function (pdfDocument, baseUrl) {
|
||||
|
||||
this.baseUrl = baseUrl;
|
||||
this.pdfDocument = pdfDocument;
|
||||
this.pageRefs = Object.create(null);
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.setHistory = function (pdfHistory) {
|
||||
|
||||
this.pdfHistory = pdfHistory;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.navigateTo = function (destination) {
|
||||
|
||||
var self = this,
|
||||
destString = "",
|
||||
destinationPromise,
|
||||
goToDestination;
|
||||
|
||||
goToDestination = function (destRef) {
|
||||
|
||||
var pageNumber;
|
||||
|
||||
if (destRef instanceof Object) {
|
||||
pageNumber = self._cachedPageNum(destRef);
|
||||
} else if ((destRef | 0) === destRef) { // Integer
|
||||
pageNumber = destRef + 1;
|
||||
} else {
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "' + destRef
|
||||
+ '" is not a valid destination reference.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageNumber) {
|
||||
|
||||
if (pageNumber < 1 || pageNumber > self.pagesCount) {
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "' + pageNumber
|
||||
+ '" is a non-existent page number.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.reader.queuePage(pageNumber);
|
||||
|
||||
} else {
|
||||
|
||||
self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
|
||||
self.cachePageRef(pageIndex + 1, destRef);
|
||||
goToDestination(destRef);
|
||||
}).catch(function () {
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "', destRef,
|
||||
'" is not a valid page reference.');
|
||||
|
||||
return;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
destString = destination;
|
||||
destinationPromise = self.pdfDocument.getDestination(destination);
|
||||
|
||||
} else {
|
||||
|
||||
destinationPromise = Promise.resolve(destination);
|
||||
|
||||
}
|
||||
|
||||
destinationPromise.then(function (_destination) {
|
||||
|
||||
destination = _destination;
|
||||
|
||||
if (!(destination instanceof Array)) {
|
||||
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "' + destination
|
||||
+ '" is not a valid destination array.');
|
||||
|
||||
return;
|
||||
}
|
||||
goToDestination(destination[0]);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.getDestinationHash = function (destination) {
|
||||
|
||||
var url = this.baseUrl,
|
||||
str;
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
url += "#"
|
||||
+ (parseInt(destination) === destination)
|
||||
? "nameddest="
|
||||
: ""
|
||||
+ escape(destination);
|
||||
|
||||
} else if (destination instanceof Array) {
|
||||
|
||||
url += "#"
|
||||
+ escape(JSON.stringify(destination));
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.setHash = function (hash) {
|
||||
var reader = this,
|
||||
pageNumber,
|
||||
dest;
|
||||
|
||||
if (hash.indexOf('=') >= 0) {
|
||||
var params = parseQueryString(hash);
|
||||
if ('search' in params) {
|
||||
this.eventBus.dispatch('findfromurlhash', {
|
||||
source: this,
|
||||
query: params['search'].replace(/"/g, ''),
|
||||
phraseSearch: (params['phrase'] === 'true')
|
||||
});
|
||||
}
|
||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||
if ('nameddest' in params) {
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.updateNextHashParam(params.nameddest);
|
||||
}
|
||||
this.navigateTo(params.nameddest);
|
||||
return;
|
||||
}
|
||||
if ('page' in params) {
|
||||
pageNumber = (params.page | 0) || 1;
|
||||
}
|
||||
if ('zoom' in params) {
|
||||
// Build the destination array.
|
||||
var zoomArgs = params.zoom.split(','); // scale,left,top
|
||||
var zoomArg = zoomArgs[0];
|
||||
var zoomArgNumber = parseFloat(zoomArg);
|
||||
|
||||
if (zoomArg.indexOf('Fit') === -1) {
|
||||
// If the zoomArg is a number, it has to get divided by 100. If it's
|
||||
// a string, it should stay as it is.
|
||||
dest = [null, { name: 'XYZ' },
|
||||
zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null,
|
||||
zoomArgs.length > 2 ? (zoomArgs[2] | 0) : null,
|
||||
(zoomArgNumber ? zoomArgNumber / 100 : zoomArg)];
|
||||
} else {
|
||||
if (zoomArg === 'Fit' || zoomArg === 'FitB') {
|
||||
dest = [null, { name: zoomArg }];
|
||||
} else if ((zoomArg === 'FitH' || zoomArg === 'FitBH') ||
|
||||
(zoomArg === 'FitV' || zoomArg === 'FitBV')) {
|
||||
dest = [null, { name: zoomArg },
|
||||
zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null];
|
||||
} else if (zoomArg === 'FitR') {
|
||||
if (zoomArgs.length !== 5) {
|
||||
console.error('PDFLinkService_setHash: ' +
|
||||
'Not enough parameters for \'FitR\'.');
|
||||
} else {
|
||||
dest = [null, { name: zoomArg },
|
||||
(zoomArgs[1] | 0), (zoomArgs[2] | 0),
|
||||
(zoomArgs[3] | 0), (zoomArgs[4] | 0)];
|
||||
}
|
||||
} else {
|
||||
console.error('PDFLinkService_setHash: \'' + zoomArg +
|
||||
'\' is not a valid zoom value.');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dest) {
|
||||
|
||||
reader.queuePage(pageNumber || this.page);
|
||||
|
||||
} else if (pageNumber) {
|
||||
this.page = pageNumber; // simple page
|
||||
}
|
||||
if ('pagemode' in params) {
|
||||
this.eventBus.dispatch('pagemode', {
|
||||
source: this,
|
||||
mode: params.pagemode
|
||||
});
|
||||
}
|
||||
} else { // Named (or explicit) destination.
|
||||
if ((typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) &&
|
||||
isPageNumber(hash) && hash <= this.pagesCount) {
|
||||
console.warn('PDFLinkService_setHash: specifying a page number ' +
|
||||
'directly after the hash symbol (#) is deprecated, ' +
|
||||
'please use the "#page=' + hash + '" form instead.');
|
||||
this.page = hash | 0;
|
||||
}
|
||||
|
||||
dest = unescape(hash);
|
||||
try {
|
||||
dest = JSON.parse(dest);
|
||||
|
||||
if (!(dest instanceof Array)) {
|
||||
// Avoid incorrectly rejecting a valid named destination, such as
|
||||
// e.g. "4.3" or "true", because `JSON.parse` converted its type.
|
||||
dest = dest.toString();
|
||||
}
|
||||
} catch (ex) {}
|
||||
|
||||
if (typeof dest === 'string' || this.isValidExplicitDestination(dest)) {
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.updateNextHashParam(dest);
|
||||
}
|
||||
this.navigateTo(dest);
|
||||
return;
|
||||
}
|
||||
console.error('PDFLinkService_setHash: \'' + unescape(hash) +
|
||||
'\' is not a valid destination.');
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.executeNamedAction = function (action) {
|
||||
// See PDF reference, table 8.45 - Named action
|
||||
switch (action) {
|
||||
case 'GoBack':
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.back();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'GoForward':
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.forward();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NextPage':
|
||||
if (this.page < this.pagesCount) {
|
||||
this.page++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PrevPage':
|
||||
if (this.page > 1) {
|
||||
this.page--;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'LastPage':
|
||||
this.page = this.pagesCount;
|
||||
break;
|
||||
|
||||
case 'FirstPage':
|
||||
this.page = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break; // No action according to spec
|
||||
}
|
||||
|
||||
this.eventBus.dispatch('namedaction', {
|
||||
source: this,
|
||||
action: action
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.onFileAttachmentAnnotation = function (params) {
|
||||
this.eventBus.dispatch('fileattachmentannotation', {
|
||||
source: this,
|
||||
id: params.id,
|
||||
filename: params.filename,
|
||||
content: params.content,
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.pageRefStr = function (pageRef) {
|
||||
|
||||
return pageRef.num + ' ' + pageRef.gen + ' R';
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.cachePageRef = function (pageNum, pageRef) {
|
||||
|
||||
this.pageRefs[this.pageRefStr(pageRef)] = pageNum;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype._cachedPageNum = function (pageRef) {
|
||||
|
||||
return (this.pageRefs[this.pageRefStr(pageRef)])
|
||||
|| null;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.isValidExplicitDestination = function (dest) {
|
||||
if (!(dest instanceof Array)) {
|
||||
return false;
|
||||
}
|
||||
var destLength = dest.length, allowNull = true;
|
||||
if (destLength < 2) {
|
||||
return false;
|
||||
}
|
||||
var page = dest[0];
|
||||
if (!(typeof page === 'object' &&
|
||||
typeof page.num === 'number' && (page.num | 0) === page.num &&
|
||||
typeof page.gen === 'number' && (page.gen | 0) === page.gen) &&
|
||||
!(typeof page === 'number' && (page | 0) === page && page >= 0)) {
|
||||
return false;
|
||||
}
|
||||
var zoom = dest[1];
|
||||
if (!(typeof zoom === 'object' && typeof zoom.name === 'string')) {
|
||||
return false;
|
||||
}
|
||||
switch (zoom.name) {
|
||||
case 'XYZ':
|
||||
if (destLength !== 5) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'Fit':
|
||||
case 'FitB':
|
||||
return destLength === 2;
|
||||
case 'FitH':
|
||||
case 'FitBH':
|
||||
case 'FitV':
|
||||
case 'FitBV':
|
||||
if (destLength !== 3) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'FitR':
|
||||
if (destLength !== 6) {
|
||||
return false;
|
||||
}
|
||||
allowNull = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
for (var i = 2; i < destLength; i++) {
|
||||
var param = dest[i];
|
||||
if (!(typeof param === 'number' || (allowNull && param === null))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
34
files_reader/vendor/pdfjs/services/simple_link_service.js
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
PDFJS.Reader.SimpleLinkService = function () {
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Object.defineProperties(PDFJS.Reader.SimpleLinkService, {
|
||||
'page': {
|
||||
get: function () { return 0; },
|
||||
set: function(value) {}
|
||||
}
|
||||
});
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.navigateTo = function (destUrl) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.getDestinationHash = function (destination) {
|
||||
return "#";
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.getAnchorUrl = function (anchor) {
|
||||
return "#";
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.setHash = function (hash) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.executeNamedAction = function (action) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.onFileAttachmentAnnotation = function (params) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.cachePageRef = function (pageNum, pageRef) {
|
||||
};
|