@@ -15,13 +15,7 @@ export async function init(id, invoke, options) {
1515
1616 await addLink ( './_content/BootstrapBlazor.PdfReader/css/pdf.css' ) ;
1717
18- //const elementId = el.querySelector('canvas');
19- //const pdf = new Pdf(elementId);
20- //pdf.scale = scale;
21- //pdf.rotation = rotation;
22-
2318 const loadingTask = pdfjsLib . getDocument ( options ) ;
24-
2519 loadingTask . onProgress = function ( progressData ) {
2620 console . log ( progressData . loaded , progressData . total ) ;
2721 } ;
@@ -47,9 +41,12 @@ export async function init(id, invoke, options) {
4741
4842
4943 eventBus . on ( "pagesinit" , function ( ) {
50- // We can use pdfViewer now, e.g. let's change default scale.
51- pdfViewer . currentScaleValue = "page-width" ;
52- console . log ( "pagesInit" ) ;
44+ if ( options . isFitToPage ) {
45+ pdfViewer . currentScaleValue = 1.0 ;
46+ }
47+ else {
48+ pdfViewer . currentScaleValue = "page-width" ;
49+ }
5350 } ) ;
5451
5552 // handle the promise
@@ -82,8 +79,22 @@ export async function init(id, invoke, options) {
8279 Data . set ( id , pdfViewer ) ;
8380}
8481
82+ export function fitToPage ( id ) {
83+ const pdfViewer = Data . get ( id ) ;
84+ if ( pdfViewer ) {
85+ pdfViewer . currentScaleValue = 1.0 ;
86+ }
87+ }
88+
89+ export function fitToWidth ( id ) {
90+ const pdfViewer = Data . get ( id ) ;
91+ if ( pdfViewer ) {
92+ pdfViewer . currentScaleValue = "page-width" ;
93+ }
94+ }
95+
8596export function dispose ( id ) {
86- Data . remove ( id ) ;
97+ Data . get ( id ) ;
8798}
8899
89100function getCanvas ( item ) {
0 commit comments