Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the removePageBorders option, in PDFViewer, to only GENERIC builds #15998

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions web/pdf_viewer.css
Expand Up @@ -78,10 +78,12 @@
height: var(--viewer-container-height);
}

/*#if GENERIC*/
.pdfViewer.removePageBorders .page {
margin: 0 auto 10px;
border: none;
}
/*#endif*/

/*#if COMPONENTS*/
.pdfViewer.singlePageView {
Expand All @@ -107,7 +109,9 @@
white-space: nowrap;
}

/*#if GENERIC*/
.pdfViewer.removePageBorders,
/*#endif*/
.pdfViewer.scrollHorizontal .spread,
.pdfViewer.scrollWrapped .spread {
margin-left: 0;
Expand All @@ -131,12 +135,14 @@
margin-right: var(--spreadHorizontalWrapped-margin-LR);
}

/*#if GENERIC*/
.pdfViewer.removePageBorders .spread .page,
.pdfViewer.removePageBorders.scrollHorizontal .page,
.pdfViewer.removePageBorders.scrollWrapped .page {
margin-left: 5px;
margin-right: 5px;
}
/*#endif*/

.pdfViewer .page canvas {
margin: 0;
Expand Down
24 changes: 18 additions & 6 deletions web/pdf_viewer.js
Expand Up @@ -254,7 +254,6 @@ class PDFViewer {
this.downloadManager = options.downloadManager || null;
this.findController = options.findController || null;
this._scriptingManager = options.scriptingManager || null;
this.removePageBorders = options.removePageBorders || false;
this.textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE;
this.#annotationMode =
options.annotationMode ?? AnnotationMode.ENABLE_FORMS;
Expand All @@ -266,6 +265,7 @@ class PDFViewer {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
this.removePageBorders = options.removePageBorders || false;
this.renderer = options.renderer || RendererType.CANVAS;
}
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
Expand Down Expand Up @@ -307,7 +307,10 @@ class PDFViewer {
this._onBeforeDraw = this._onAfterDraw = null;
this._resetView();

if (this.removePageBorders) {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this.removePageBorders
) {
this.viewer.classList.add("removePageBorders");
}

Expand Down Expand Up @@ -1183,7 +1186,10 @@ class PDFViewer {
// "doubling" the total border width.
hPadding *= 2;
}
} else if (this.removePageBorders) {
} else if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this.removePageBorders
) {
hPadding = vPadding = 0;
} else if (this._scrollMode === ScrollMode.HORIZONTAL) {
[hPadding, vPadding] = [vPadding, hPadding]; // Swap the padding values.
Expand Down Expand Up @@ -1350,9 +1356,15 @@ class PDFViewer {
y = destArray[3];
width = destArray[4] - x;
height = destArray[5] - y;
const hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;
const vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;

let hPadding = SCROLLBAR_PADDING,
vPadding = VERTICAL_PADDING;

if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this.removePageBorders
) {
hPadding = vPadding = 0;
}
widthScale =
(this.container.clientWidth - hPadding) /
width /
Expand Down