open specific page of pdf on button click

56 views
Skip to first unread message

kvgc

unread,
Mar 11, 2022, 3:40:36 PM3/11/22
to TiddlyWiki
I use a lot of pdfs on an everyday basis and what I wanted to do was something along the lines of :

When a button is pressed, it should open the pdf with a specific page number in another tiddler.

This allows for referencing specific pages on the pdf which I find very useful at times. Are there any plugins that would do this?


----------------------------

I was able to get this functionality as follows:
* Run a simple http server on my pdfs folder
* I add a field called pdftitle to the tiddler with the path to the pdf (e.g., pdftitle="sample.pdf")
* The following script creates a button which upon clicking will open another tiddler with the sample.pdf embedded into it and also navigate to page-5.

\define concatenate(par1) {{!!pdftitle}}$par1$

<div>
<$wikify name="newtitle" text=<<concatenate  "#page=5">> >
<$button style="color:blue;">
<$action-sendmessage $message="tm-new-tiddler" pagetitle=<<newtitle>> title="viewPage" text="""<object data={{!!pagetitle}}
   type="application/pdf" style="width: 100%; height: 820px" ></object>"""  />
 Page-5
</$button>
</$wikify>


The issue with this method though is that I am unable to turn this script into a 'macro' that I can call  (e.g., <<ref-pdf page-5>> ). Would appreciate any thoughts on how to about this.

Thanks!
--
kvgc

Screenshot from 2022-03-11 12-31-03.png
Reply all
Reply to author
Forward
0 new messages