How to generate link to PDF from current url

I’ve looked on the forums and google for this, and I can’t find anything exactly right:

I have a universal navigation, one link is “Print PDF” - I don’t want to hand code each page individually.

How can I use the current page url - such as “website.com/accomodations.php” to print a PDF named after the page, like “accomodations.pdf”, or even better “pdfs/accomodations.php”?

OR just any way to print a PDF associated with the current page - I guess it doesn’t necessarily need to be the URL that links the files.

Thanks in advance for your help!

not really javascript, but have you looked up regular expressions and mod_rewrite?

You could have php build a url based on the current request and have apache redirect the ‘fake’ url to the appropriate pdf file based on variable values in the url string.