Thank You page on contribution form. Print option for the PDF that is emailed as "receipt.pdf"
Not tested yet, but can you try calling /civicrm/contribute/invoice?reset=1&amp;id=&lt;contribution_id&gt;&amp;cid=&lt;contact_id&gt; in the href instead of javascript:window.print()?
Note that the token &lt;contribution_id&gt; is the payment id that was created after you submitted the contribution form. &lt;contact_id&gt; is the id of the contact to which contribution belongs. Check if you can already get this in the thankyou template variables. More info - https://docs.civicrm.org/dev/en/latest/tools/debugging/#in-smarty-template-files
Also, make sure you've permission to download the invoice. I think civi requires either access CiviContribute or view my invoices.
UPDATE - For Joomla - The url is - /index.php?option=com_civicrm&amp;task=civicrm/contribute/invoice&amp;reset=1&amp;id=&lt; contribution_id&gt;&amp;cid=&lt;contact_id&gt;