ngx-extended-pdf-viewer: PDF data not loaded, until I'm performing any action in the pdf viewer

Hello,

recently i upgraded PDF viewer version from 0.9.24 to 0.9.54 (with no code changes except lib version ), what can i observe in 0.9.24 pdf data rendered perfectly but when tried with 0.9.54, i have to perform some action either change page number or click spread menu in pdf viewer to load the data.

Can you please take a look and let me know if i have to set any param on initialization for release version 0.9.54 compare to 0.9.24.

------------------------Template Code ---------------------------

  <ngx-extended-pdf-viewer *ngIf="currentPdf"
                           [src]="currentPdf"
                           useBrowserLocale="false"
                           style="height: 100%; width: 100%"
                           [delayFirstView]="1000"
                           [showHandToolButton]="true"
                           [handTool] = false>
  </ngx-extended-pdf-viewer>

--------------------------component code -------------------------

  ngOnInit() {
    this.displayPdf();
  }

  displayPdf() {

    // setTimeout(() => {
      this.service.getPdfExtractedContentById(this.contentId)
        .pipe(first())
        .subscribe(
          data => {
            this.currentPdf = URL.createObjectURL(this.b64toBlob(data.ExtractedByte,'data:application/pdf;base64', 1024));
            
          },
          error => {
            console.log(error);
          }
        );
    // }, 500);

  }

  b64toBlob(b64Data, contentType, sliceSize) {
    const byteCharacters = atob(b64Data);
    const byteArrays = [];
    for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
      const slice = byteCharacters.slice(offset, offset + sliceSize);

      const byteNumbers = new Array(slice.length);
      for (let i = 0; i < slice.length; i++) {
        byteNumbers[i] = slice.charCodeAt(i);
      }

      const byteArray = new Uint8Array(byteNumbers);
      byteArrays.push(byteArray);
    }

    const blob = new Blob(byteArrays, {type: contentType});
    return blob;
  }

Thank you Wajed

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

I will give a try with version 1.0.0-rc.1 and let you know.