Jump to content

Get PDF PageNumber using JS


azago

Recommended Posts

 

Is it possible to press UniButton to know the current page of the pdf displayed in a UniPDFFrame using JS ?

 

in the viewer.js i see 

    key: 'page',
    get: function get() {
      return this.pdfViewer.currentPageNumber;
    },
    set: function set(value) {
      this.pdfViewer.currentPageNumber = value;
    }
or in internet i found

iFrame.contentDocument.getElementById('pageNumber').value

 

but I can't use it in a call js

Thanks

Angelo

 

 

 

Link to comment
Share on other sites

2 hours ago, azago said:

Is it possible to press UniButton to know the current page of the pdf displayed in a UniPDFFrame using JS ?

Maybe you wanted something like this:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniPDFFrame1.JSInterface.JSCode('if ('#1'.iframe&&'#1'.iframe.contentDocument.getElementById("pageNumber")){alert('#1'.iframe.contentDocument.getElementById("pageNumber").value)};');
end;

 

Link to comment
Share on other sites

Thanks Sherzod,

the code works well !!

Now I have tried to execute a command to go to a page of the pdf through code js using this command

 

 (take from https://stackoverflow.com/questions/31615248/pdf-js-changing-current-page-number-programmatically)

 MainForm.pdfFrame.JSInterface.JSCode('if ('#1'.iframe&&'#1'.iframe.contentDocument.getElementById("docIframe")){'#1'.iframe.contentDocument.getElementById("docIframe").contentWindow.PDFViewerApplication.page=' + Uniedit1.Text +' };');

but not work (I'm a little poor in java).

 

any ideas on how to do it?

 

Thanks as always

Angelo

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...