Skip to content

Instantly share code, notes, and snippets.

@m0wn1ka
Created March 8, 2024 11:20
Show Gist options
  • Save m0wn1ka/23396e73957837f1e2e120b3e57e42ee to your computer and use it in GitHub Desktop.
Save m0wn1ka/23396e73957837f1e2e120b3e57e42ee to your computer and use it in GitHub Desktop.
read the gist for description
/* scenario of usage
- reading a pdf of say 100 pages
- index page has numbers to each chapters
- those are not the exact numbers to by typed in toolbar
- say the book chapter 1 starts on page 19
- so index pages shows chapter1---- page1
- so we need to manually go thorugh them and check each page whether we reached the inteneded page or not
*/
/*description of inputs
- as first input we give the page number of first page
- usig the same example we give 19
- 19(tool bar page no)--------1(index page mention page no)
- as second input we give page no we want to go :as per index page
*/
/* description of code
- .page[data-page-number]
- each pdf page has this strucutre
- the class is page and a attribute with data-page-number with corresponding page number
- so we select the correspondign element usign query selector
- and use scroll into view to go to that correspoding page
*/
/* how to use
just copy paste it in the console of devolper tools in the browser tab where pdf is opened
*/
const initial=parseInt(prompt("give relateive page no of 1(tool bar page no of index pageno)"))
const num=parseInt(prompt("givethe page number u want to go(as mentioned in the index page)"))
document.querySelector(`.page[data-page-number='${num+initial}']`).scrollIntoView()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment