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

JS code in PDF document not working at all #13918

Open
ousia opened this issue Aug 20, 2021 · 2 comments
Open

JS code in PDF document not working at all #13918

ousia opened this issue Aug 20, 2021 · 2 comments

Comments

@ousia
Copy link

ousia commented Aug 20, 2021

Attach (recommended) or Link to PDF file here:
PDF document with some JS inside

Configuration:

  • Web browser and its version: Firefox 91.
  • Operating system and its version: Windows 7.
  • PDF.js version: the latest shipped with Firefox.
  • Is a browser extension: Yes.

Steps to reproduce the problem:

  1. Open the attached document.

  2. Contained JS code in the PDF document:

    this.pageNum = this.numPages ;
    
    function GoToFirstSlide(label) {
      this.pageNum = 0 ;
    }
    
    function GoToLastSlide(label) {
      this.pageNum = this.numPages ;
    }
    
    function GoToNextSlide(label) {
      ++this.pageNum ;
    }
    
    function GoToPreviousSlide(label) {
      --this.pageNum ;
    }
    
    function SwitchFS() {
      if (app.fs.isFullScreen == true)
        app.fs.isFullScreen = false ;
      else
        app.fs.isFullScreen = true ;
    }
  3. Neither buttons nor even the first line works.

What is the expected behavior? (add screenshot)

PDF.js should open page 25 (the last one) instead of page 1 (the first one).

What went wrong? (add screenshot)

JavaScript seems not to be implemented at all.

Many thanks for your help.

@calixteman
Copy link
Contributor

JavaScript is implemented for fields (see https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=440&zoom=auto,-215,499) but not for annotations.
It shouldn't be that hard to do but it's likely some work.

@ousia
Copy link
Author

ousia commented Sep 4, 2021

Many thanks for your reply, @calixteman.

I thought that this.pageNum = this.numPages ; wasn’t related to annotations.

But I must admit I don’t know how JS works in PDF documents.

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

No branches or pull requests

3 participants