From e7b5071b169393101fcf851124639ea122bb82f9 Mon Sep 17 00:00:00 2001 From: rlesavre Date: Tue, 23 Jun 2020 12:27:30 +0200 Subject: [PATCH 1/2] feat(zoom): give the possibility to choose between page-fit, page-width and page-height when original-size is false, and setting zoom --- README.md | 23 ++++++++++- src/app/app.component.html | 13 ++++++- src/app/app.component.ts | 1 + src/app/material.module.ts | 8 +++- src/app/pdf-viewer/pdf-viewer.component.ts | 45 ++++++++++++++-------- 5 files changed, 70 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 5cef0724c..0393bccb5 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ export class AppComponent { * [[render-text-mode]](#render-text-mode) * [[rotation]](#rotation) * [[zoom]](#zoom) +* [[zoom-scale]](#zoom-scale) * [[original-size]](#original-size) * [[fit-to-page]](#fit-to-page) * [[show-all]](#show-all) @@ -127,7 +128,7 @@ export class AppComponent { | [src] | *string, object, UInt8Array* | Required | Pass pdf location - + ``` [src]="'https://vadimdez.github.io/ng2-pdf-viewer/pdf-test.pdf'" ``` @@ -135,7 +136,7 @@ Pass pdf location For more control you can pass options object to ```[src]```. [See other attributes for the object here](https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L128-L204). Options object for loading protected PDF would be: - + ```js { url: 'https://vadimdez.github.io/ng2-pdf-viewer/pdf-test.pdf', @@ -253,6 +254,24 @@ Zoom pdf [zoom]="0.5" ``` +#### [zoom-scale] + +| Property | Type | Required | +| --- | ---- | --- | +| [zoom-scale] | *'page-width'\|'page-fit'\|'page-height'* | *Optional* | + +Defines how the Zoom scale is computed when `[original-size]="false"`, by default set to 'page-width'. + +- *'page-width'* with zoom of 1 will display a page width that take all the possible horizontal space in the container + +- *'page-height'* with zoom of 1 will display a page height that take all the possible vertical space in the container + +- *'page-fit'* with zoom of 1 will display a page that will be scaled to either width or height to fit completely in the container + +``` +[zoom-scale]="page-width" +``` + #### [original-size] | Property | Type | Required | diff --git a/src/app/app.component.html b/src/app/app.component.html index a0e13a7a5..4fb6a87a8 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -60,6 +60,15 @@ + + Select an option + + Page Width + Page Height + Page Fit + + +