diff --git a/app/src/main/assets/viewer.css b/app/src/main/assets/viewer.css
index 83977ee7d..98cf37ac6 100644
--- a/app/src/main/assets/viewer.css
+++ b/app/src/main/assets/viewer.css
@@ -68,3 +68,17 @@ body, canvas, #padding {
.textLayer .endOfContent.active {
top: 0px;
}
+
+html, body {
+ display: table;
+ height: 100%;
+ width: 100%;
+ text-align:center;
+}
+
+#content-wrapper {
+ display: flex;
+ justify-content: center; /* center horizontally */
+ align-items: center;
+ height: 100%;
+}
\ No newline at end of file
diff --git a/app/src/main/assets/viewer.html b/app/src/main/assets/viewer.html
index bea467826..3bbac2ac2 100644
--- a/app/src/main/assets/viewer.html
+++ b/app/src/main/assets/viewer.html
@@ -7,8 +7,9 @@
-
-
+
+
+
diff --git a/app/src/main/assets/viewer.js b/app/src/main/assets/viewer.js
index c11db9b06..e37d44f7a 100644
--- a/app/src/main/assets/viewer.js
+++ b/app/src/main/assets/viewer.js
@@ -1,6 +1,5 @@
"use strict";
-const padding = document.getElementById("padding");
let pdfDoc = null;
let pageRendering = false;
let renderPending = false;
@@ -54,7 +53,6 @@ function display(newCanvas, zoom) {
canvas.width = newCanvas.width;
canvas.style.height = newCanvas.style.height;
canvas.style.width = newCanvas.style.width;
- padding.style.width = canvas.style.width;
canvas.getContext("2d", { alpha: false }).drawImage(newCanvas, 0, 0);
if (!zoom) {
scrollTo(0, 0);
@@ -95,7 +93,7 @@ function renderPage(pageNumber, zoom, prerender, prerenderTrigger=0) {
return;
}
- const viewport = page.getViewport({scale: newZoomRatio, rotation: orientationDegrees})
+ const viewport = page.getViewport({scale: window.screen.width / page.getViewport({scale: 1}).width * newZoomRatio, rotation: orientationDegrees})
if (useRender) {
if (newZoomRatio !== zoomRatio) {
@@ -200,7 +198,9 @@ function isTextSelected() {
function updateInset() {
const windowInsetTop = channel.getWindowInsetTop() / window.devicePixelRatio + "px";
- padding.style.paddingTop = windowInsetTop;
+ canvas.style.paddingTop = windowInsetTop;
+ // bottom insets was added to ensure that the PDF is in center
+ canvas.style.paddingBottom = windowInsetTop;
textLayerDiv.style.top = windowInsetTop;
}
diff --git a/app/src/main/java/org/grapheneos/pdfviewer/PdfViewer.java b/app/src/main/java/org/grapheneos/pdfviewer/PdfViewer.java
index 606a1da79..01038f954 100644
--- a/app/src/main/java/org/grapheneos/pdfviewer/PdfViewer.java
+++ b/app/src/main/java/org/grapheneos/pdfviewer/PdfViewer.java
@@ -76,8 +76,8 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
"usb 'none'; " +
"vr 'none'";
- private static final float MIN_ZOOM_RATIO = 0.5f;
- private static final float MAX_ZOOM_RATIO = 1.5f;
+ private static final float MIN_ZOOM_RATIO = 0.9f;
+ private static final float MAX_ZOOM_RATIO = 3f;
private static final int ALPHA_LOW = 130;
private static final int ALPHA_HIGH = 255;
private static final int ACTION_OPEN_DOCUMENT_REQUEST_CODE = 1;
@@ -88,7 +88,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
private Uri mUri;
public int mPage;
public int mNumPages;
- private float mZoomRatio = 1f;
+ private float mZoomRatio = MIN_ZOOM_RATIO;
private int mDocumentOrientationDegrees;
private int mDocumentState;
private int windowInsetTop;