Display PDF inside tiddler

2,409 views
Skip to first unread message

Bill Denbigh

unread,
Feb 27, 2015, 3:30:40 PM2/27/15
to tiddl...@googlegroups.com
I am trying to display the contents of a PDF file within a tiddler in stream with the other text. Is this possible? I thought i simply could use the [myPDF[img:myCoolPDF.pdf]] but was wrong. Can anyone please suggest how to display a PDF other than to link out to it like this [[myPDF|File:myCoolPDF.pdf]]

Thanks a ton... Bill

Bill Denbigh

unread,
Feb 27, 2015, 3:32:28 PM2/27/15
to tiddl...@googlegroups.com
Incidentally i did see the "Motovun Jack.pdf" tiddler inside of tiddlywiki.com but can't figure out how it works. Sorry...

Astrid Elocson

unread,
Feb 27, 2015, 5:09:52 PM2/27/15
to tiddl...@googlegroups.com
Hi Bill,

Use the technique shown at http://tiddlywiki.com/#ExternalImages.

You need a special tiddler to represent the PDF within your wiki. Let's say this tiddler is called CoolPDF. Set its type to application/pdf, and add a field called _canonical_uri (with an initial underscore) with Cool.pdf or whatever the file's called as its value. Both [img[MyCoolPDF]] and {{MyCoolPDF}} should then work.

– æ

Måns

unread,
Feb 27, 2015, 5:37:27 PM2/27/15
to
Hi Bill

If you have a look at the "Motovun Jack.pdf" tiddler in edit mode you'll see that it's a binary tiddler and that it's type is set to "application/pdf".
Maybe this all happens automagically when you drag a pdf on to a TW? (import it into the TW document)

I don't know because I generally avoid embedding binary files in my TWs not to create too big Tidddlywiki documents...

Instead I would create a tiddler and set the type to "application/pdf" manually - simply write it in the type field if it doesn't appear in the drop down list already.
Next I would create a new custom field: "_canonical_uri" and paste the URL to my web hosted pdf document (click add - or it won't be created).

Usually I show pdfs via an iframe: <iframe width="100%" height="900" src="URL to my web hosted pdf document" frameborder="0" allowfullscreen></iframe>.

If I have a lot of pdfs to show I will create a global macro with the iframe like this:

1) Create a tiddler called eg $:/_iframe/macro (It doesn't matter what you call it)
2) Write something like this: 
\define iframe(url)
<iframe width="100%" height="915" src="$url$" frameborder="0" allowfullscreen></iframe>
\end"
3) Tag it with $:/tags/Macro

Now I can create an iframe with my pdf like this: <<iframe "URL to my web hosted pdf document">> in any tiddler.

A more "involved version of the above macro could look like this:

1)Tiddler title eg $:/_iframe2/macro/link/fullscreen
2) Write:
\define iframe2(url)
[ext[Link|$url$]] {{$:/core/ui/Buttons/full-screen}}
<iframe width="100%" height="900" src="$url$" frameborder="0" allowfullscreen></iframe>
\end
3) Tag it with $:/tags/Macro

Now I can create an iframe with my pdf like this: <<iframe2 "URL to my web hosted pdf document">> in any tiddler. 
I'll get a link to the pdf document and a button to open the tiddler in full screen mode at the top of the iframed pdf document.

If I fetch all my pdfs from the same location I will add a "location snippet" to the macro like this: src="http://MyWebAddress/$url$.pdf"
Then there is only very little to write: <<iframe "filename">>. 
Address and filetype is already set by the macro...


Hope some of this helps - enjoy :-)

Cheers Måns Mårtensson

Bill Denbigh

unread,
Feb 28, 2015, 11:37:31 AM2/28/15
to tiddl...@googlegroups.com
This worked awesome.... Thanks. Bill

James

unread,
May 19, 2015, 12:43:23 AM5/19/15
to tiddl...@googlegroups.com
Hi Måns,

I am sorry to post a reply on the old threat.

I found your scripts really useful and it works on embedded PDF into TW5 very well.

However, I encounter a problem when I tried to embedded a local PDF file in TW5.  It pops up a download window instead of showing PDF in the iframe.  Would you mind to shed some lights on that?

Thanks.

Måns

unread,
May 19, 2015, 2:46:21 AM5/19/15
to tiddl...@googlegroups.com
Hi James

Try the <embed> tag instead:

Here's an example how to turn it into a macro:

[[$:/embedPDFmacro]] $:/tags/Macro:

\define pdfembed(url)
<embed src='$url$' type="application/pdf" width='100%' height='915'/>
\end


Usage: <<pdfembed "web adress or file path">>

You might even be able to leave out the type attribute and experiment with other filetypes too..

Cheers Måns Mårtensson
Reply all
Reply to author
Forward
0 new messages