aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-10-14 13:03:51 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-10-14 13:03:51 +0200
commit389abe953bf582e522acdf2c0e7b17b8fab3e18d (patch)
tree6b8f123d4da72d8d0906922a3b38928de802f8bc
parent7aadb86776f828f13ac16c18c2e16b17e62f5d9e (diff)
downloadpdf-as-4-389abe953bf582e522acdf2c0e7b17b8fab3e18d.tar.gz
pdf-as-4-389abe953bf582e522acdf2c0e7b17b8fab3e18d.tar.bz2
pdf-as-4-389abe953bf582e522acdf2c0e7b17b8fab3e18d.zip
JS changes to work with mobile ApplicationSnapshot
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java14
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java22
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java9
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java4
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java14
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/Blob.js211
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/FileSaver.min.js2
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/dragNdrop.js42
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js7
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/postman.js15
-rw-r--r--pdf-as-web/src/main/webapp/index.jsp4
11 files changed, 332 insertions, 12 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
index 0ad96b04..28203683 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
@@ -49,6 +49,7 @@ public class WebConfiguration implements IConfigurationConstants {
public static final String PDF_AS_WORK_DIR = "pdfas.dir";
public static final String STATISTIC_BACKEND_LIST = "statistic.backends";
public static final String ALLOW_EXT_OVERWRITE = "allow.ext.overwrite";
+ public static final String ACCESSCOUNT = "accesscount";
public static final String ALLOW_EXT_WHITELIST_VALUE_PRE = "ext.overwrite.wl.";
@@ -514,6 +515,19 @@ public class WebConfiguration implements IConfigurationConstants {
return false;
}
+ public static int getAccessCount() {
+ String value = properties.getProperty(ACCESSCOUNT);
+ int ivalue = 1;
+ if (value != null) {
+ try {
+ ivalue = Integer.parseInt(value);
+ } catch(NumberFormatException e) {
+ logger.warn(ACCESSCOUNT + " not a number", e);
+ }
+ }
+ return ivalue;
+ }
+
public static int getFilesizeThreshold() {
String value = properties.getProperty(UPLOAD_FILESIZE_THRESHOLD);
int ivalue = THRESHOLD_SIZE;
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
index ab23e238..143df335 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
@@ -127,6 +127,7 @@ public class PdfAsHelper {
private static final String PRE_PROCESSOR_MAP = "PREPROCMAP";
private static final String OVERWRITE_MAP = "OVERWRITEMAP";
private static final String KEYID = "KEYID";
+ private static final String SESSION_ACCESS = "SESSION_ACCESS";
private static final String POSITIONING_URL = "/assets/js/pdf.js/web/viewer.html";
@@ -1229,7 +1230,7 @@ public class PdfAsHelper {
}
public static void regenerateSession(HttpServletRequest request) {
- request.getSession(false).invalidate();
+ request.getSession(true).invalidate();
request.getSession(true);
}
@@ -1539,6 +1540,25 @@ public class PdfAsHelper {
}
return false;
}
+
+ public static boolean isSessionAccessCounter(HttpServletRequest request) {
+ HttpSession session = request.getSession();
+ Object obj = session.getAttribute(SESSION_ACCESS);
+ if (obj == null) {
+ Integer value = 0;
+ session.setAttribute(SESSION_ACCESS, value);
+ obj = value;
+ }
+
+ if (obj instanceof Integer) {
+ Integer count = (Integer) obj;
+ count++;
+ session.setAttribute(SESSION_ACCESS, count);
+ return (count < WebConfiguration.getAccessCount());
+ } else {
+ return false;
+ }
+ }
public static String getVersion() {
return PdfAsFactory.getVersion();
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
index 53335ba6..f701ca63 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
@@ -75,6 +75,7 @@ public class PdfAsParameterExtractor {
public static final String PARAM_OVERWRITE_PREFIX = "ov:";
public static final String PARAM_QRCODE_CONTENT = "qrcontent";
public static final String PARAM_USER_POSITIONING = "upos";
+ public static final String PARAM_BASE64 = "base64";
public static boolean isUserPositioning(HttpServletRequest request) {
String paramerterValue = (String)request.getAttribute(PARAM_USER_POSITIONING);
@@ -84,6 +85,14 @@ public class PdfAsParameterExtractor {
return false;
}
+ public static boolean isBase64(HttpServletRequest request) {
+ String paramerterValue = (String)request.getAttribute(PARAM_BASE64);
+ if(paramerterValue != null) {
+ return Boolean.parseBoolean(paramerterValue);
+ }
+ return false;
+ }
+
public static String getConnector(HttpServletRequest request) {
String connector = (String)request.getAttribute(PARAM_CONNECTOR);
if(connector != null) {
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
index 210a3cc3..ce5501c1 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
@@ -103,7 +103,7 @@ public class ExternSignServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- // PdfAsHelper.regenerateSession(request);
+ PdfAsHelper.regenerateSession(request);
logger.debug("Get signing request");
@@ -156,7 +156,7 @@ public class ExternSignServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- // PdfAsHelper.regenerateSession(request);
+ PdfAsHelper.regenerateSession(request);
logger.debug("Post signing request");
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java
index 4fce6860..cd2a8072 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +79,7 @@ public class PDFData extends HttpServlet {
protected void process(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
byte[] signedData = PdfAsHelper.getSignedPdf(request, response);
-
+
StatisticEvent statisticEvent = PdfAsHelper.getStatisticEvent(request,
response);
@@ -126,13 +127,22 @@ public class PDFData extends HttpServlet {
response.setHeader("ValueCheckCode",
String.valueOf(resp.getValueCode()));
}
+
+ //if(PdfAsParameterExtractor.isBase64(request)) {
+ // signedData = Base64.encodeBase64(signedData);
+ //}
+
+ response.setContentLength(signedData.length);
+
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(signedData);
os.close();
// When data is collected destroy session!
- request.getSession().invalidate();
+ if(!PdfAsHelper.isSessionAccessCounter(request)) {
+ request.getSession().invalidate();
+ }
} else {
PdfAsHelper.setSessionException(request, response,
"No signed pdf document available.", null);
diff --git a/pdf-as-web/src/main/webapp/assets/js/Blob.js b/pdf-as-web/src/main/webapp/assets/js/Blob.js
new file mode 100644
index 00000000..2e41b8a2
--- /dev/null
+++ b/pdf-as-web/src/main/webapp/assets/js/Blob.js
@@ -0,0 +1,211 @@
+/* Blob.js
+ * A Blob implementation.
+ * 2014-07-24
+ *
+ * By Eli Grey, http://eligrey.com
+ * By Devin Samarin, https://github.com/dsamarin
+ * License: X11/MIT
+ * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md
+ */
+
+/*global self, unescape */
+/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
+ plusplus: true */
+
+/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
+
+(function (view) {
+ "use strict";
+
+ view.URL = view.URL || view.webkitURL;
+
+ if (view.Blob && view.URL) {
+ try {
+ new Blob;
+ return;
+ } catch (e) {}
+ }
+
+ // Internally we use a BlobBuilder implementation to base Blob off of
+ // in order to support older browsers that only have BlobBuilder
+ var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
+ var
+ get_class = function(object) {
+ return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
+ }
+ , FakeBlobBuilder = function BlobBuilder() {
+ this.data = [];
+ }
+ , FakeBlob = function Blob(data, type, encoding) {
+ this.data = data;
+ this.size = data.length;
+ this.type = type;
+ this.encoding = encoding;
+ }
+ , FBB_proto = FakeBlobBuilder.prototype
+ , FB_proto = FakeBlob.prototype
+ , FileReaderSync = view.FileReaderSync
+ , FileException = function(type) {
+ this.code = this[this.name = type];
+ }
+ , file_ex_codes = (
+ "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
+ + "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
+ ).split(" ")
+ , file_ex_code = file_ex_codes.length
+ , real_URL = view.URL || view.webkitURL || view
+ , real_create_object_URL = real_URL.createObjectURL
+ , real_revoke_object_URL = real_URL.revokeObjectURL
+ , URL = real_URL
+ , btoa = view.btoa
+ , atob = view.atob
+
+ , ArrayBuffer = view.ArrayBuffer
+ , Uint8Array = view.Uint8Array
+
+ , origin = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/
+ ;
+ FakeBlob.fake = FB_proto.fake = true;
+ while (file_ex_code--) {
+ FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
+ }
+ // Polyfill URL
+ if (!real_URL.createObjectURL) {
+ URL = view.URL = function(uri) {
+ var
+ uri_info = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
+ , uri_origin
+ ;
+ uri_info.href = uri;
+ if (!("origin" in uri_info)) {
+ if (uri_info.protocol.toLowerCase() === "data:") {
+ uri_info.origin = null;
+ } else {
+ uri_origin = uri.match(origin);
+ uri_info.origin = uri_origin && uri_origin[1];
+ }
+ }
+ return uri_info;
+ };
+ }
+ URL.createObjectURL = function(blob) {
+ var
+ type = blob.type
+ , data_URI_header
+ ;
+ if (type === null) {
+ type = "application/octet-stream";
+ }
+ if (blob instanceof FakeBlob) {
+ data_URI_header = "data:" + type;
+ if (blob.encoding === "base64") {
+ return data_URI_header + ";base64," + blob.data;
+ } else if (blob.encoding === "URI") {
+ return data_URI_header + "," + decodeURIComponent(blob.data);
+ } if (btoa) {
+ return data_URI_header + ";base64," + btoa(blob.data);
+ } else {
+ return data_URI_header + "," + encodeURIComponent(blob.data);
+ }
+ } else if (real_create_object_URL) {
+ return real_create_object_URL.call(real_URL, blob);
+ }
+ };
+ URL.revokeObjectURL = function(object_URL) {
+ if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
+ real_revoke_object_URL.call(real_URL, object_URL);
+ }
+ };
+ FBB_proto.append = function(data/*, endings*/) {
+ var bb = this.data;
+ // decode data to a binary string
+ if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
+ var
+ str = ""
+ , buf = new Uint8Array(data)
+ , i = 0
+ , buf_len = buf.length
+ ;
+ for (; i < buf_len; i++) {
+ str += String.fromCharCode(buf[i]);
+ }
+ bb.push(str);
+ } else if (get_class(data) === "Blob" || get_class(data) === "File") {
+ if (FileReaderSync) {
+ var fr = new FileReaderSync;
+ bb.push(fr.readAsBinaryString(data));
+ } else {
+ // async FileReader won't work as BlobBuilder is sync
+ throw new FileException("NOT_READABLE_ERR");
+ }
+ } else if (data instanceof FakeBlob) {
+ if (data.encoding === "base64" && atob) {
+ bb.push(atob(data.data));
+ } else if (data.encoding === "URI") {
+ bb.push(decodeURIComponent(data.data));
+ } else if (data.encoding === "raw") {
+ bb.push(data.data);
+ }
+ } else {
+ if (typeof data !== "string") {
+ data += ""; // convert unsupported types to strings
+ }
+ // decode UTF-16 to binary string
+ bb.push(unescape(encodeURIComponent(data)));
+ }
+ };
+ FBB_proto.getBlob = function(type) {
+ if (!arguments.length) {
+ type = null;
+ }
+ return new FakeBlob(this.data.join(""), type, "raw");
+ };
+ FBB_proto.toString = function() {
+ return "[object BlobBuilder]";
+ };
+ FB_proto.slice = function(start, end, type) {
+ var args = arguments.length;
+ if (args < 3) {
+ type = null;
+ }
+ return new FakeBlob(
+ this.data.slice(start, args > 1 ? end : this.data.length)
+ , type
+ , this.encoding
+ );
+ };
+ FB_proto.toString = function() {
+ return "[object Blob]";
+ };
+ FB_proto.close = function() {
+ this.size = 0;
+ delete this.data;
+ };
+ return FakeBlobBuilder;
+ }(view));
+
+ view.Blob = function(blobParts, options) {
+ var type = options ? (options.type || "") : "";
+ var builder = new BlobBuilder();
+ if (blobParts) {
+ for (var i = 0, len = blobParts.length; i < len; i++) {
+ if (Uint8Array && blobParts[i] instanceof Uint8Array) {
+ builder.append(blobParts[i].buffer);
+ }
+ else {
+ builder.append(blobParts[i]);
+ }
+ }
+ }
+ var blob = builder.getBlob(type);
+ if (!blob.slice && blob.webkitSlice) {
+ blob.slice = blob.webkitSlice;
+ }
+ return blob;
+ };
+
+ var getPrototypeOf = Object.getPrototypeOf || function(object) {
+ return object.__proto__;
+ };
+ view.Blob.prototype = getPrototypeOf(new view.Blob());
+}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
diff --git a/pdf-as-web/src/main/webapp/assets/js/FileSaver.min.js b/pdf-as-web/src/main/webapp/assets/js/FileSaver.min.js
new file mode 100644
index 00000000..8bbbf769
--- /dev/null
+++ b/pdf-as-web/src/main/webapp/assets/js/FileSaver.min.js
@@ -0,0 +1,2 @@
+/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
+var saveAs=saveAs||function(e){"use strict";if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in r,o=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),f=e.webkitRequestFileSystem,u=e.requestFileSystem||f||e.mozRequestFileSystem,s=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},c="application/octet-stream",d=0,l=500,w=function(t){var r=function(){if(typeof t==="string"){n().revokeObjectURL(t)}else{t.remove()}};if(e.chrome){r()}else{setTimeout(r,l)}},p=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var i=e["on"+t[r]];if(typeof i==="function"){try{i.call(e,n||e)}catch(o){s(o)}}}},v=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob(["\ufeff",e],{type:e.type})}return e},y=function(t,s,l){if(!l){t=v(t)}var y=this,m=t.type,S=false,h,R,O=function(){p(y,"writestart progress write writeend".split(" "))},g=function(){if(R&&a&&typeof FileReader!=="undefined"){var r=new FileReader;r.onloadend=function(){var e=r.result;R.location.href="data:attachment/file"+e.slice(e.search(/[,;]/));y.readyState=y.DONE;O()};r.readAsDataURL(t);y.readyState=y.INIT;return}if(S||!h){h=n().createObjectURL(t)}if(R){R.location.href=h}else{var i=e.open(h,"_blank");if(i==undefined&&a){e.location.href=h}}y.readyState=y.DONE;O();w(h)},b=function(e){return function(){if(y.readyState!==y.DONE){return e.apply(this,arguments)}}},E={create:true,exclusive:false},N;y.readyState=y.INIT;if(!s){s="download"}if(i){h=n().createObjectURL(t);r.href=h;r.download=s;setTimeout(function(){o(r);O();w(h);y.readyState=y.DONE});return}if(e.chrome&&m&&m!==c){N=t.slice||t.webkitSlice;t=N.call(t,0,t.size,c);S=true}if(f&&s!=="download"){s+=".download"}if(m===c||f){R=e}if(!u){g();return}d+=t.size;u(e.TEMPORARY,d,b(function(e){e.root.getDirectory("saved",E,b(function(e){var n=function(){e.getFile(s,E,b(function(e){e.createWriter(b(function(n){n.onwriteend=function(t){R.location.href=e.toURL();y.readyState=y.DONE;p(y,"writeend",t);w(e)};n.onerror=function(){var e=n.error;if(e.code!==e.ABORT_ERR){g()}};"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=y["on"+e]});n.write(t);y.abort=function(){n.abort();y.readyState=y.DONE};y.readyState=y.WRITING}),g)}),g)};e.getFile(s,{create:false},b(function(e){e.remove();n()}),b(function(e){if(e.code===e.NOT_FOUND_ERR){n()}else{g()}}))}),g)}),g)},m=y.prototype,S=function(e,t,n){return new y(e,t,n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){if(!n){e=v(e)}return navigator.msSaveOrOpenBlob(e,t||"download")}}m.abort=function(){var e=this;e.readyState=e.DONE;p(e,"abort")};m.readyState=m.INIT=0;m.WRITING=1;m.DONE=2;m.error=m.onwritestart=m.onprogress=m.onwrite=m.onabort=m.onerror=m.onwriteend=null;return S}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!=null){define([],function(){return saveAs})} \ No newline at end of file
diff --git a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js
index 62270ece..76a68c62 100644
--- a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js
+++ b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js
@@ -18,6 +18,29 @@ var local_success = false;
var keystore_success = false;
var place_on_new_page = false;
+function getArrayBuffer(data) {
+ if (typeof data !== 'string') {
+ return data;
+ }
+ var length = data.length;
+ var array = new Uint8Array(length);
+ for (var i = 0; i < length; i++) {
+ array[i] = data.charCodeAt(i) & 0xFF;
+ }
+ return array.buffer;
+}
+
+function getArrayBase64(base64) {
+ var raw = window.atob(base64);
+ var rawLength = raw.length;
+ var array = new Uint8Array(new ArrayBuffer(rawLength));
+
+ for (i = 0; i < rawLength; i++) {
+ array[i] = raw.charCodeAt(i);
+ }
+ return array;
+}
+
function registerEventListeners() {
var locale = "EN";
var connector = "mobilebku";
@@ -122,7 +145,22 @@ function registerEventListeners() {
$("#DownloadResultButton").attr("title", "The download is valid only once!");
$("#DownloadResultButton").css("pointer-events", "none");
- //window.open($("#DownloadResultButton").attr("href"));
+ /*
+ var isFileSaverSupported = false;
+ try {
+ isFileSaverSupported = !!new XMLHttpRequest;
+ } catch (e) {}
+
+ if(isFileSaverSupported) {
+ evt.preventDefault();
+ $.get( $("#DownloadResultButton").attr("href") + "?base64=true", function( data ) {
+ var array = getArrayBase64(data);
+ saveAs(new Blob([array], { type: "application/pdf" }), "signed.pdf");
+ });
+ }
+ */
+ evt.preventDefault();
+ window.open($("#DownloadResultButton").attr("href"));
//return false;
});
@@ -590,7 +628,7 @@ function toggleLanguage()
{
$("#LanguageDisplay").html
(
- "<span class='label label-info'><span class='flag-icon flag-icon-de'></span> DE</span>"
+ "<span class='label label-info'><span class='flag-icon flag-icon-at'></span> AT</span>"
);
default_language = "en";
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
index 1af630d6..d21f5d51 100644
--- 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
@@ -458,8 +458,6 @@ function makeSignatureDraggable(signature) {
//
function updateSignaturePosition(signature) {
var page = signature.page;
- var canvas_height = $("#page" + page.toString()).attr("height");
- var current_scale = PDFViewerApplication.pdfViewer.currentScale;
var thisPos = $(signature.sig).position();
var x;
var y;
@@ -467,9 +465,10 @@ function updateSignaturePosition(signature) {
x = thisPos.left;
y = thisPos.top;
+ var pdfPos = PDFViewerApplication.pdfViewer.pages[page-1].viewport.convertToPdfPoint(x, y);
- signature.posx = Math.floor(x / current_scale / (4.0/3.0)).toString();
- signature.posy = Math.floor((parseInt(canvas_height) - (y)) / current_scale / (4.0/3.0)).toString();
+ signature.posx = pdfPos[0];
+ signature.posy = pdfPos[1];
last_left = $("#img_signature").css("left");
diff --git a/pdf-as-web/src/main/webapp/assets/js/postman.js b/pdf-as-web/src/main/webapp/assets/js/postman.js
new file mode 100644
index 00000000..e13c0ee7
--- /dev/null
+++ b/pdf-as-web/src/main/webapp/assets/js/postman.js
@@ -0,0 +1,15 @@
+// postMessage
+// ----------------------------------------------------------------------
+/*
+ * nojquery-postmessage by Jeff Lee
+ * a non-jQuery fork of:
+ *
+ * jQuery postMessage - v0.5 - 9/11/2009
+ * http://benalman.com/projects/jquery-postmessage-plugin/
+ *
+ * Copyright (c) 2009 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
+//----------------------------------------------------------------------
diff --git a/pdf-as-web/src/main/webapp/index.jsp b/pdf-as-web/src/main/webapp/index.jsp
index 283d1294..c823d044 100644
--- a/pdf-as-web/src/main/webapp/index.jsp
+++ b/pdf-as-web/src/main/webapp/index.jsp
@@ -10,6 +10,8 @@
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery-ui.min.js"></script>
<script src="assets/js/pdf.js/build/pdf.js"></script>
+ <script src="assets/js/Blob.js"></script>
+ <script src="assets/js/FileSaver.min.js"></script>
<script src="assets/js/dragNdrop.js"></script>
<script src="assets/js/jquery-lang.js"></script>
<script src="assets/js/js.cookie.js"></script>
@@ -36,7 +38,7 @@
<!-- Header -->
<div class="row" id="LanguageSwitchContainer">
<h2 id="PageTitle" class="pull-left" lang="en">PDF-Signature Online</h2>
- <h4 id="LanguageDisplay" class="pull-right"><span class="label label-info"><span class="flag-icon flag-icon-de"></span> DE</span></h4>
+ <h4 id="LanguageDisplay" class="pull-right"><span class="label label-info"><span class="flag-icon flag-icon-at"></span> AT</span></h4>
</div>
<div class="row center">
<div class="" id="navBar">