Print a web page to PDF and retain links

I'm in 18.04 and trying to print a web page to PDF, which works fine if I choose "Print to file" from the print menu. The catch is that there doesn't seem to be a way to preserve the links on the page. I've tried a few different web pages and it doesn't seem to matter -- printing to PDF from the print dialog doesn't retain any links.

I don't see anything I can touch in the settings, and this particular page is only available to logged in users on a Drupal site so I can't just use a command line tool to pull it.

Is there a workable way to print a web page to PDF and retain all the links?

1 Answer

Assuming you're using Firefox, this is a long-standing request (12 years and counting).

There are some alternatives listed in this Super User post, some of them being:

  • Use some extension to Firefox

    I didn't feel like adding random extensions for this, so I haven't tested any.

  • Use wkhtmltopdf

    I got some odd font-rendering issues (top half of monospace fonts were cut off). Not sure why. Otherwise the PDF looked good. One user suggests using pandoc via LaTeX conversion.

    Probably won't work for authenticated pages.

  • Use Chrome/Chromium.

    This is what I ended up doing. It's automateable:

    google-chrome-stable --headless --disable-gpu --run-all-compositor-stages-before-draw --print-to-pdf=some-file.pdf proto://some-uri

    You might be able to rely on saved cookies with Chrome to avoid the login issue.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like