diff options
Diffstat (limited to 'pdf-as-web/src/main/webapp/assets/js/pdf.js/web')
3 files changed, 73 insertions, 15 deletions
diff --git a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js new file mode 100644 index 00000000..bb2c89d7 --- /dev/null +++ b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js @@ -0,0 +1,53 @@ +window.addEventListener("message", function (evt) { + var goto_last_page_on_render = false; + var file = evt.data; + var fileReader = new FileReader(); + var current_page = null; + console.log("child:" + file); + + function rendered(evt) { + console.log(evt); + if(goto_last_page_on_render) { + document.getElementById("lastPage").click(); + return; + } + showSignatureBlock(); + console.log(evt); + current_page = PDFView.page; + document.removeEventListener('textlayerrendered', rendered); + document.addEventListener('textlayerrendered', showSignatureBlock); + } + + window.addEventListener('pagechange', showSignatureBlock); + document.addEventListener('textlayerrendered', rendered); + + fileReader.onload = function(evt) { + var buffer = evt.target.result; + var uint8Array = new Uint8Array(buffer); + PDFView.open(uint8Array, 0); + }; + + function showSignatureBlock(evt) { + console.log(evt); + if(PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1).renderingState === RenderingStates.RUNNING) { + return; + } + + console.log(document.readyState); + $(".img_signature").remove(); + $("#pageContainer"+PDFView.page).prepend("<img src='../../../img/signature.png' alt='Signature' id='img_signature' class='cl_signature' draggable='true' style='position: absolute; z-index:4;'>"); + $(".cl_signature").draggable({ + drag: function() { + + }, + containment: "parent" + }); + } + + fileReader.readAsArrayBuffer(file); +}, false); + + + + + diff --git a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html index b3af4ada..6dae1b7b 100644 --- a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html +++ b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html @@ -24,23 +24,23 @@ http://sourceforge.net/adobe/cmap/wiki/License/ <meta name="google" content="notranslate"> <title>PDF.js viewer</title> - <link rel="stylesheet" href="viewer.css"/> - + <script src="compatibility.js"></script> - - -<!-- This snippet is used in production (included from viewer.html) --> -<link rel="resource" type="application/l10n" href="locale/locale.properties"/> -<script src="l10n.js"></script> -<script src="../build/pdf.js"></script> - - + <!-- This snippet is used in production (included from viewer.html) --> + <link rel="resource" type="application/l10n" href="locale/locale.properties"/> + + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> + <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script> + + <script src="l10n.js"></script> + <script src="../build/pdf.js"></script> <script src="debugger.js"></script> <script src="viewer.js"></script> - + <script src="app.js"></script> + </head> <body tabindex="1" class="loadingInProgress"> diff --git a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js index 34c44e46..9801be2f 100644 --- a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js +++ b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js @@ -27,7 +27,7 @@ 'use strict'; -var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf'; +var DEFAULT_URL = ''; var DEFAULT_SCALE_DELTA = 1.1; var MIN_SCALE = 0.25; var MAX_SCALE = 10.0; @@ -5843,7 +5843,7 @@ var PDFViewerApplication = { function getDocumentCallback(pdfDocument) { self.load(pdfDocument, scale); self.loading = false; - }, + }, function getDocumentError(exception) { var message = exception && exception.message; var loadingErrorMessage = mozL10n.get('loading_error', null, @@ -6666,14 +6666,18 @@ window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias function webViewerLoad(evt) { - PDFViewerApplication.initialize().then(webViewerInitialized); + //PDFViewerApplication.initialize().then(webViewerInitialized); + PDFViewerApplication.initialize().then(function() { + webViewerInitialized(); + window.parent.postMessage("asdf yooooooo","*"); + }); } function webViewerInitialized() { var queryString = document.location.search.substring(1); var params = PDFViewerApplication.parseQueryString(queryString); var file = 'file' in params ? params.file : DEFAULT_URL; - + var fileInput = document.createElement('input'); fileInput.id = 'fileInput'; fileInput.className = 'fileInput'; @@ -7005,6 +7009,7 @@ window.addEventListener('change', function webViewerChange(evt) { if (!files || files.length === 0) { return; } + var file = files[0]; if (!PDFJS.disableCreateObjectURL && |