Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Made a sad discovery today. I have Ubuntu 10.04 LTS. My client is in the ad business and she had a marketing competition task for me. She wanted me to visit websites of the competitors, and export the home pages as PDF. However, she wanted me to do so with embedded hyperlinks.

As it turns out, Firefox (and even the latest Chrome) on Ubuntu 10.04 LTS do not embed hyperlinks in PDF web page exports.

Sure, there are several Chrome and FF plugins that let you export as PDF, but what these do is connect to the URL remotely, generate the PDF remotely, and then force a download in your browser to download it from a remote location. That's not good for me, though, because some of these competitor pages require an initial login. That means that all I get back on the PDF printing from these FF or Chrome plugins is a login page.

Is there a way to get around this problem, to fix the broken PDF printer on Ubuntu 10.04?

share|improve this question
    
Someone suggested httrack on Twitter. Unfortunately tools like that, wget, and curl do not have a way to get past a login screen, which must be done manually. Therefore, these tools would end up showing nothing but a login screen when you try to download the product specs page. –  Volomike Jan 18 '11 at 3:15

1 Answer 1

up vote 3 down vote accepted

The tool to use is called wkhtmltopdf, this tool is in the repositories but all compiled repository versions don't have the embeded link functionality due to the hackish changes to some qt libraries.

So install wkhtmltopdf from the repositories to get all the dependencies:

sudo apt-get install wkhtmltopdf

Then download the static version from here. Unpack the file to your desktop and then move to bin:

sudo mv Desktop/wkhtmltopdf-i386 /usr/bin/wkhtmltopdf-static

Now you can use the tool to generate pdf files with links:

wkhtmltopdf-static http://google.com google.pdf

For your websites with the login requirement, you need to log in via firefox and then export the cookie file using the Export Cookies firefox plugin. With a cookies.txt you can then run:

wkhtmltopdf-static --cookie-jar cookies.txt http://google.com google.pdf

I know a lot of these needs to be done on the command line, but it's the best way to do it and you get a lot more control. wkhtmltopdf is quite a powerful tool.

share|improve this answer
    
This is just so awesome. Thanks. –  Volomike Jan 19 '11 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.