If a book has 9 pages each digit is used exactly once. If a book has 99 pages, each digit is used 10 tines in the ones place and ten times in the tens place or 20 times. If the book has 999 pages each digit is used in the ones place 100 times, the tens place 100 times, and the hundreds place 100 times or 300 times.
So if the book has 9999....9 = $10^k-1$ pages, each digit is $10^{k-1} $ times in each of the $k $ positions so each digit is used $k*10^{k-1} $.
So if, say, the number $5$ is used $7349$ times then:
$4000 < 7349 < 50000$ so there are between $9999$ and $99999$ pages. The digit $5$ was used $4000$ up to page $9999$ so the remaining $3349$ were used in pages $10,000$ through $99,999$.
Between $10,000$ through $19,999$ each digit, except 1, appears another $4000$ times so there fewer than $19,999$ pages.
Between $10,000$ and $10,999$ each digit except 1 and 0 appear 300 times. Between $11,000$ and $11,999$ another 300 times. So between $10,000$ and $14,999$ the digit $5$ occurs $5*300=1500$ times.
We still have $1849$ occurrences to account for.
From $15,000$ the $15,999$ the digit $5$ has occured $300$ times in the ones, tens, and hundreds place, just like before, in in the thousands place it has occured $1000$ times. This accounts for $1,300$ more times. We have $549$ more occurences to account for.
Pages, $16,000$ to $17,000$, again account for $300$ and $17,000$ to $18,000$ will account for $300$ more. So we know the book has between, $17,000$ and $17,999$ pages.
We have $249$ more occurences to account for. Between $17,000$ and $17,100$ each digit (except 1 and 7) occur $20$ times so between $17,000$ and $17,499$ the digit $5$ occurs $5*20=100$ times. We have 149 occurences to account for. Between $17,500$ and $17,599$ the $5$ occurs 20 times in the one and tens place, but $100$ times in the hundreds. So that accounts for $120$ more and we have $29$ more to go.
$17,600$ to $17,700$ account for $20$ more leaving just $9$. Between $17,700$ and $17,749$ there are $5$ occurences in the ones position. $4$ more to go.
$17,750-17,753$ account fo the last $4$ occurences.
The book has exactly $17,753$ pages.
Note, not all numbers have answers. $7350$ would put as at $17,754$ pages but $17,755$ pages makes the number $7352$. The number $7351$ is impossible.
Also not all numbers have an exact number of pages. If there were say, exactly $3$ of the digit $5$, then we could have had anywhere between $25 - 34$ pages.