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

(pdfjs-dist) Multiple Errors on PDFFindController, PDFThumbnailViewer, and PDFPageProxy: null or undefined #10270

Closed
dapperdandev opened this issue Nov 20, 2018 · 2 comments

Comments

@dapperdandev
Copy link

dapperdandev commented Nov 20, 2018

Viewer Repo/Link

  • Sorry :(. Private, company repo.

Configuration:

  • Web browser and its version: 70.0.3538.102
  • Operating system and its version: 2.0.943
  • PDF.js version: 2.0.943 (pdfjs-dist)

Steps to Reproduce

  1. install the latest pdfjs-dist and attempt utilizing PDFJSViewer.PDFFindController
  2. Attempt to new up PDFFindController, PDFThumbnailViewer
const PDFJSViewer = require('pdfjs-dist/web/pdf_viewer');

class ViewerComponent {
        ...
        this.findController = new PDFJSViewer.PDFFindController({ pdfViewer: this.pdfViewer });
        this.pdfViewer.setFindController(this.findController);
        ...
}

  1. Additionally, the PDFPageProxy appears to have changed it's shape:
import { PDFPageProxy } from 'pdfjs-dist';

export class PdfPage {

    constructor(public proxy: PDFPageProxy) { }

    ...

    get removed(): boolean {
        return !!this.proxy['pageInfo'].removed; // <-- Cannot read property 'removed' of undefined
    }
    ...
}

What is the expected behavior?

  • No errors in the console
  • Viewer Renders

What went wrong?
Primarily, the following two errors. It seems like minor changes happened to the library in a semantically patch level release. E.g., from 2.0.489 to 2.0.943 has breaking changes.

  • this.pdfViewer.setFindController is not a function
  • this.findController.reset is not a function
  • a couple of others around PDFThumbnailViewer and PDFPageProxy

image

image

@timvandermeij
Copy link
Contributor

timvandermeij commented Nov 20, 2018

Most of the changes were made in #10099 and follow-up patches, so the usage indeed needs to be adapted. It was done to both improve code quality and fix bugs, but also because we received feedback from third-party application developers that wanted to use the find controller in their own viewer, so we made it more modular and less dependent on the PDFViewer instance.

It seems like minor changes happened to the library in a semantically patch level release. E.g., from 2.0.489 to 2.0.943 has breaking changes.

Yes, but this was expected. Version 2.0.943 is the actual stable release, whereas earlier versions like 2.0.489 were pre-release (beta) versions that were expected to change. We published the beta version because there was a demand for it and to gather feedback for the final stable version. So, anything before 2.0.943 in the 2.x release series was never stable and thus the API could still change, whereas now it can't until the next major version.

@dapperdandev
Copy link
Author

Okay. Thank you for the response. My mistake.

We had forked and heavily modified ng2-pdf-viewer which was relying on 2.0.489 at the time, which is also why I didn't even think to look to see if it was a pre-release version (dependency of a dependency).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants