Thank you all for the help and sorry for the delayed response.
Since I am a noobie, I tested the solution by @EricShulman and created a summary (Version 3 and Version 4 are my favorites):
Summary
Note: The the tiddler has the same title as the PDF (without the ending .pdf
).
Version 1: Using variable $(var)$
and absolute file path works perfectly!
\define filepath_v1() file:///C:/Users/Patrick/MyFiles/$(currentTiddler)$.pdf
<$button>
<$action-sendmessage $message="tm-open-external-window" $param=<<filepath_v1>> windowName="_tiddlywiki" windowFeatures="height=1000, width=1250, top=0, left=0"/>
Open filepath_v1
</$button>
Version 2: Using transclusion {{!!title}}
with $wikify
widget and absolute file path works perfectly!
\define filepath_v2() file:///C:/Users/Patrick/MyFiles/{{!!title}}.pdf
<$button>
<$wikify name="thispath" text=<<filepath_v2>> >
<$action-sendmessage $message="tm-open-external-window" $param=<<thispath>> windowName="_tiddlywiki" windowFeatures="height=1000, width=1250, top=0, left=0"/>
Open filepath_v2
</$wikify>
</$button>
Version 3: Same as Version 1 just with relative path according to docu under External Links. The PDF is in the folder assets works perfectly!
\define filepath_v3() ./assets/$(currentTiddler)$.pdf
<$button>
<$action-sendmessage $message="tm-open-external-window" $param=<<filepath_v3>> windowName="_tiddlywiki" windowFeatures="height=1000, width=1250, top=0, left=0"/>
Open filepath_v3
</$button>
Version 4: Alternative to </$button>
using rectangle shape with href
works perfectly!
\define filepath_v4() ./assets/$(currentTiddler)$.pdf
<div style="font-size:0.5em;text-align:left;margin:0em auto;">
<a href=<<filepath_v4>> class="tc-btn-big-green" style="border-radius:4px;background-color:#696969;" target="_blank" rel="noopener noreferrer">
{{$:/core/images/file}} ''Open File''
</a>
</div>
Rendered as:
Extra note:
-
The same also works for images. Only the file ending under the command /define
has to be changed to .png
, .jpg
, etc.
-
Using \define filepath() $(currentTiddler)$.pdf
automatically creates the full file path to the TiddlyWiki.html
file adding $(currentTiddler)$.pdf
to the file path.
For example:
define filepath() $(currentTiddler)$.pdf
results in
file:///C:/Users/Patrick/MyFiles/$(currentTiddler)$.pdf
and if the PDF is in a subfolder
define filepath() assets/$(currentTiddler)$.pdf
results in
file:///C:/Users/Patrick/MyFiles/assets/$(currentTiddler)$.pdf
Both examples work.
-
Using the latest Firefox version under:
Windows: The file opens in a new window.
MacOS: The file opens in a new tab using the same code (I do not know why).