Clickable links in PDF rendering

3,449 views
Skip to first unread message

Thomas Parisot

unread,
Dec 12, 2012, 11:12:17 AM12/12/12
to phan...@googlegroups.com
Hello everybody,

I generated a PDF rendering of a Webpage. Text is selectable (only on Linux – for a weird reason on OSX it's not the case with PhantomJS 1.7).
I have been surprised to see hyperlinks are not clickable within the text.

Is there some special thing to setup (option or something else) for that?
Or is it planned to land in PhantomJS 1.8?

Any help would be appreciated, thanks :-)

Ariya Hidayat

unread,
Dec 29, 2012, 5:59:15 PM12/29/12
to phan...@googlegroups.com
This has been reported many times, check the issue tracker.

Unfortunately this is a limitation of Qt PDF engine. It is possible to
fix it, however it's pretty low priority for me. Any contribution from
anyone is of course very welcomed!


Regards,


--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat
http://gplus.to/ariyahidayat

Thomas Parisot

unread,
Dec 31, 2012, 8:25:20 AM12/31/12
to phan...@googlegroups.com
Hi and thanks for this reply :-)

I've digged into wkhtmltopdf and encountered the same issue. Yet they propose static builds embedding patched version of QT, fixing the problem.

Sadly I'm not skilled at all in C, neither familiar with Qt to help you on this topic.
Sorry :-(

I can only thank you a lot for this useful tool!



--
You received this message because you are subscribed to the Google Groups "phantomjs" group.
Visit this group at http://groups.google.com/group/phantomjs?hl=en.





--
Thomas PARISOT
Développeur Web expérimenté, JavaScript full-stack
http://case.oncle-tom.net/ @oncletom

James Greene

unread,
Dec 31, 2012, 9:31:24 AM12/31/12
to phan...@googlegroups.com

Thomas:
Do you share the link that discusses the patched version of Qt? Thanks!
~~James

Thomas Parisot

unread,
Dec 31, 2012, 9:42:28 AM12/31/12
to phan...@googlegroups.com
It is subtely evocated here http://code.google.com/p/wkhtmltopdf/wiki/compilation.
There is a link towards a custom version of QT located here: http://gitorious.org/+wkhtml2pdf/qt/wkhtmltopdf-qt


Here you go!

j...@devantlatele.com

unread,
Jan 24, 2013, 9:45:57 AM1/24/13
to phan...@googlegroups.com
Hi,

I added more details about webkit versions in the bug report :


JY

Yair Lenga

unread,
Jul 12, 2013, 5:30:53 PM7/12/13
to phan...@googlegroups.com
Thomas, JY, Arida,

Having clickable links in the generate PDF will be extremely useful for one of my project.
I have experience with "C", and access to Linux dev box.

Can you share any work/ideas that you already did toward addressing this bug ?

Yair.

On Thursday, January 24, 2013 9:45:57 AM UTC-5, j...@devantlatele.com wrote:

Yair Lenga

unread,
Jul 12, 2013, 5:33:21 PM7/12/13
to phan...@googlegroups.com
Ariya,

Will it be possible to add Javascript API calls to submit the links into the PDF layer (similar to PDFMark). The Javascript can extract the links from the DOM.

Yair Lenga

Thomas Parisot

unread,
Jul 15, 2013, 6:54:06 AM7/15/13
to phan...@googlegroups.com
Hi,

I had to switch to a patched version of wkhmltopdf, inject some custom javascript and render the content.
It's a bit more old school but it was not too much hard work to make the phantomJS code working.

thomas....@ubermetrics-technologies.com

unread,
Jul 15, 2013, 10:28:11 AM7/15/13
to phan...@googlegroups.com
Hi Thomas,

can you share some more details?

Thanks, Thomas

Thomas Parisot

unread,
Jul 15, 2013, 11:33:47 AM7/15/13
to phan...@googlegroups.com
You can find out the working code here: https://coderwall.com/p/aej2aq

I basically did that to make a PDF copy of a newsletter, with a slightly different output.

I started doing that with CasperJS (so PhantomJS) but I ran into this non-clickable bug which made me switching to wkhtmltopdf.

Let me know if it helped you :-)

zhu jun

unread,
Jan 22, 2014, 10:10:32 PM1/22/14
to phan...@googlegroups.com
Hi Ariya,

I had the same issue with PhantomJS 1.9.2. It seems wkhtmltopdf had the same issue 4 years ago:


Antialize had committed the fix on Qt:


It turns out the Qt used by PhantomJS has already got that fix.

So I guess probably we could do something simply to get this working? I will see if I can get it done.

Cheers,

Antonin Stefanutti

unread,
Jun 4, 2015, 12:27:57 PM6/4/15
to phan...@googlegroups.com
Hi All,

I've pushed a PR on Github for this: https://github.com/ariya/phantomjs/pull/13250

I've tested successfully in these examples: https://github.com/astefanutti/decktape#examples

I've pushed the changes as well directly on Qt side: https://bugreports.qt.io/browse/QTBUG-44563

It's under review though there is not that much update: https://codereview.qt-project.org/#/c/112842/

Antonin
https://github.com/astefanutti
https://twitter.com/astefanut
Reply all
Reply to author
Forward
0 new messages