3

I'm trying to link PDF to features in QGIS. I do that by putting the path in a column named "PDF" and execute the default open action or a generic action command.

So basically I don't have any problems when putting the absolute path, but when I try putting the relative path, it doesn't work. For example, ./PDF/example.pdf doesn't work but C:/Users/myname/Desktop/project/PDF/example.pdf works. If I'm correct, the . is supposed to be where the project file is.

So far, these two methods worked for opening a pdf:

The default open action and this as action text:

[%"PDF"%]

without "enable capture"

or

with a generic action :

cmd /c [%"PDF"%] 

or

cmd /c [%"PDF"%] 

(both worked at one point, I think it was depending if I put "" in the path column).

I tried several things, for example replacing the / with \ or putting "" in the path column but nothing works and I can't open pdf file with the relative path. I guess my error is simple, but I browsed the net for hours and couldn't find a solution...

EDIT

Even if I change the properties to relative path, the path is still not recognized...

path not in blue

1 Answer 1

2

You can do that in several ways, depending on you purpose. Here is one way:

  1. Create the attribute with the relative path (it should start with './' . Use it as append (Adjunto in spanish) in formulary. (Porperties)

enter image description here

  1. Go to the formulary of a point and see if it is now in hyperlinked blue.

enter image description here


Update: 2022-01-26

You can compose the route with a function like this.

[%concat(@project_folder , "PDFDIRWIN" )%]

Where PDFDIRWIN is the relative path without the starting point (you can keep ip and rewrite the function removing it if you prefer).

enter image description here

Don't know why it does't work directly with relatives, but with this you can do the same.

6
  • 1
    I just tried it but the path was not in blue, and therefore I still can't open it... (see my edit)
    – Wicowan
    Jan 24, 2022 at 16:43
  • 1
    THANK YOU, after trying everything even Python, this finally worked !!! thanks so much
    – Wicowan
    Jan 26, 2022 at 14:58
  • I'm glad it worked :-) Jan 26, 2022 at 15:06
  • I have a last little thing to ask... So it works when my path is like this : /PDF/pdf01.pdf, but if I want the path like this: PDF/pdf01.pdf, why doesn't this [%concat(@project_folder , "/", "DirPDF" )%] work ?
    – Wicowan
    Jan 26, 2022 at 15:10
  • 1
    Yep I was going to comment that strangely, single quote worked, I had no idea why until now, thanks again :)
    – Wicowan
    Jan 26, 2022 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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