TransWikia.com

How to create relative hyperlinks in QGIS PDF output

Geographic Information Systems Asked by ASHHart on November 10, 2020

I am attempting to add text labels in the composer that will result in clickable relative hyperlinks in the PDF output.

Adding a text label, ticking “Render as HTML” and adding www.google.com results in a clickable hyperlink from the PDF to Google. However, i’m struggling to generate a clickable relative hyperlink in the PDF. I’m aware the format of a relative path needs to use rather than /. Ive even attempted to wrap it in the following HTML code: Link but does not help.

How do I create a clickable relative hyperlink in the PDF output please?

Two related questions are:
Clickable HTML link in QGIS print composer pdf export?

Creating Mapbook with Hyperlink texts in PDF using QGIS Atlas?

Ive tried this in QGIS 3.0.3

2 Answers

You should to use variable @project_folder in expresion for action.

Type=Python

Action text=

from PyQt4.QtCore import QUrl;
from PyQt4.QtWebKit import QWebView;

myWV = QWebView(None);
myWV.load(QUrl("file:///[% @project_folder || '/' || "link" %]"));
myWV.show()

enter image description here

Answered by Carlos López Quintanilla on November 10, 2020

Not possible, unfortunately. PDF definitely supports relative links but there is a known issue in QGIS which prevents HTML links in general from performing as expected.

The issue is marked as "won't fix" because it is inherited from the QT library rather than a problem with QGIS itself.

As a workaround, your best bet is probably to use a separate PDF editor to add links manually once the document has been exported. If you need to handle a large number of maps/pages with links based on attributes, consider an InDesign-based workflow with a data merge to automatically add links to each page.

Answered by carstoid on November 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP