Search code examples
ionic4pdf-viewerpdfview

view pdf file in ionic 4 - page like terms and condition


I work in ionic 4 , and i want to make page contains 2 controls "PDF Viewer , checkbox" like Terms and condition

i cannot found any solution like this page , anyone have any idea or solution ?

Thank you


Solution

  • I had used ng2-pdf-viewer plugin from https://github.com/vadimdez/ng2-pdf-viewer/

    1- npm install ng2-pdf-viewer --save

    2- Add PdfViewerModule to your module's imports

       import { PdfViewerModule } from 'ng2-pdf-viewer';
    
    
    
      @NgModule({
        imports: [BrowserModule, PdfViewerModule],
        declarations: [AppComponent],
          bootstrap: [AppComponent]
         })
    

    3- create your page for exapmpe pdf-viewer-page and in the module page add the import of your libarary import { PdfViewerModule } from 'ng2-pdf-viewer';

    @NgModule({
      imports: [
        CommonModule,
        FormsModule,
        IonicModule,
        HeaderModule,
        RouterModule.forChild(routes),
        PdfViewerModule,
        PinchZoomModule,
      ],
    

    4- in your html page

    use thie tag

    <pdf-viewer [src]="'https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf'"   style="display: block;" [zoom]="pdfZoom" [rotation]="rotation"
             [original-size]="false" [show-all] ="false" [page]="page"
             (after-load-complete)="afterLoadComplete($event)" ></pdf-viewer>
    

    I hope this help you