silverstripe / cwp-pdfexport

Adds PDF export capability for CWP pages
BSD 3-Clause "New" or "Revised" License
4 stars 6 forks source link

generatePDF() generates relative links for "Link to: A Page" and "Link to: Download a File" links #10

Open robbieaverill opened 6 years ago

robbieaverill commented 6 years ago

Migrated from GitLab

cc @PsukheDelos

This can be replicated on a local dev environment with a base install of the CWP 1.7.0 Recipe with PDF Exporting enabled.

External links, Email links, etc. appear to work as expected. However, links that were created via "Link to: A Page" and "Link to: Download a File".

"Link to: Download a File"

Create a page and add a Link to download a file. If you inspect any of that element on the page, you'll see the link appears as: href="/assets/Test.png".

"Link to: A Page"

On this same page, Add a Link to a page. A link to a contact us page, for example, would look like: href="/contact-us/"

Export the PDF and open it in your System Viewer. (Viewing inside Chrome's built in PDF Viewer can mask the issue). Click on any of the links and it will attempt to serve the link from the base url of "file:///" instead of the expected "http://cwp.local/"

robbieaverill commented 6 years ago

So we might need to rewrite relative URLs to be absolute during the PDF generation process

dhensby commented 6 years ago

HTTP::absoluteURLs() to the rescue :)

robbieaverill commented 5 years ago

I've moved this to the pdfexport repository, assuming it affects CWP 2.x as well