I'm trying to setup the links on this page: to lead to specific pages within this PDF: https://fiftyallstars.com/a2z.pdf --- I've found I can lead people to whatever page like this: https://fiftyallstars.com/a2z.pdf#page=7 but I'd like to lead them to a page based on Today's date. I've added a few example pages to the end of the PDF that have 12/01/19 etc. in the header section. I figure if the browser's "find" functionality can scroll to that page, then there should be some javascript that can do the same.

Any help would be awesome. Thanks!

Here are some helpful links I've found so far:

Appending the URL link with today's date: https://stackoverflow.com/questions/27728219/how-to-insert-todays-date-into-a-url

Leading to a specific destination within the PDF: ---

Setting markers within the document that have the date instead: https://stackoverflow.com/questions/125632/is-it-possible-to-link-to-a-bookmark-within-a-pdf-using-url-parameters

Dani AI

Generated

Short answer for : do the date->page mapping in the page HTML with JavaScript and rewrite your PDF links to include the #page= fragment. The page fragment is the most reliable fragment to jump a browser PDF viewer to a specific page (it is part of the PDF fragment spec and is widely supported in practice). PDFObject examples — practical test notes. PDF fragment identifiers / ISO spec notes. (pdfobject.com)

A minimal client-side pattern (run in levels.html) — keep a small date->page map and update links with a class or id:

<script>
(function(){
  var d = new Date();
  var mm = ('0'+(d.getMonth()+1)).slice(-2);
  var dd = ('0'+d.getDate()).slice(-2);
  var yy = String(d.getFullYear()).slice(-2);
  var today = mm + '/' + dd + '/' + yy;

  var map = {
    '12/01/19': 7,
    '12/02/19': 8
    /* add your date => page entries */
  };

  var page = map[today] || 1;
  document.querySelectorAll('.daily-pdf-link').forEach(function(a){
    a.href = a.href.replace(/(#.*)?$/, '') + '#page=' + page;
  });
})();
</script>

Server-side generation or named destinations (good catch by ) is the alternative if you need control for non-JS clients or want the PDF itself to expose anchors. Adding named destinations inside the PDF (so you can link #nameddest=MyDateAnchor) is cleaner, but support for non-page open-parameters (search, highlight, advanced fragments) varies by viewer; browser-built viewers differ and text-based search/fragments are not consistently reliable. For text-fragment features and viewer behavior see the PDF.js viewer options and the discussion about search/text-fragment support. (github.com)

Notes: if pages are scanned images you will need OCR or named destinations; always test links in Chrome, Firefox and Edge (and mobile) because viewers behave differently.

You can also output a pdf through PHP, you just need to set the header as a pdf: headers for pdf download (and just take off the dowload part).

If you did that you would have more control over where the pdf jumps to on opening, for example you could use the built in php date() function to jump to the page you want based on the current day and work out through php which page that would be.

This is more advanced but you can also generate pdfs on the fly using TCPDF I use this a lot to generate all sorts of documents and letters on demand

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.