Displaying inline pdfs using pdf.js

4,176 views
Skip to first unread message

Meta

unread,
May 9, 2012, 11:46:16 PM5/9/12
to TiddlyWiki
Mozilla's new pdf.js seems ideal for a lightweight method to display
pdfs in tiddlers.

This simple implementation is already practically ideal for this
purpose:
http://jsbin.com/pdfjs-prevnext-v2/edit#html,live

Has anyone tried turning this into a plugin? I've gotten as far as
getting it to display the first page of a pdf inside a tiddler, but
making the back/forward buttons work is testing my skills.

PMario

unread,
May 10, 2012, 10:28:49 AM5/10/12
to TiddlyWiki
Hi,
This project is quite interesting. But ...

I had a look at the github source, 1.3 MByte (uncompressed) is 3 times
as much as a vanilla TW itself. Just for viewing PDFs, I wouldn't want
to carry that around within a TW.

I personally would use the browser plugin [1], which will be
automatically updated. There may be plugins for other browsers too.

have fun!
-mario
[1] https://addons.mozilla.org/en-US/firefox/addon/pdfjs/

Meta

unread,
May 10, 2012, 12:01:03 PM5/10/12
to TiddlyWiki
THanks for your reply mario. Yes, for many purposes the browser plugin
may be better, but I still think there are benefits to rendering
documents with pdf.js (mainly portability). A compromise would be to
load the pdf.js file directly from github. I've tried this and it
works. This way it will stay automatically updated, the only downside
is no pdf viewing without an internet connection. But then, if your
pdf files are also remote this will not be a problem.

Måns

unread,
May 10, 2012, 4:30:23 PM5/10/12
to TiddlyWiki
Hi Meta

I use google's document viewer via an iframe for showing pdfs and
powepoint presentations in tiddlers ..

Checkout: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html

You can easily turn it into a transclusion replacing the url with a
variable...

[[MyPdfViewer]]

<html><iframe src="http://docs.google.com/gview?url=$1&embedded=true"
style="width:600px; height:500px;" frameborder="0"></iframe></html>

and use it like this: <<tiddler MyPdfViewer with: [[my pdf's
address]]>>

Enjoy Måns Mårtensson

Meta

unread,
May 12, 2012, 11:51:06 AM5/12/12
to TiddlyWiki
Thanks for your suggestion Måns. The main drawback of using the Google
document viewer is, as that site says, that the pdfs need to be
online. I like to use Tiddlywiki to organise my local pdf collection.
I have the Tiddlywiki generate a listing based on the pdf files in a
certain directory and want to develop a template that will allow me to
easily navigate back and forth between the text of the pdf and my
notes on it. So far PMario's browser plugin solution is working quite
well, but I'm still planning to look into writing a tiddlywiki plugin
for maximum portability.

P.S. PMario, I just discovered your "simplicity" tiddlyspace and I
really love it!

On May 11, 6:30 am, Måns <humam...@gmail.com> wrote:
> Hi Meta
>
> I use google's document viewer via an iframe for showing pdfs and
> powepoint presentations in tiddlers ..
>
> Checkout:http://googlesystem.blogspot.com/2009/09/embeddable-google-document-v...

andrew.j.harrison84

unread,
May 16, 2012, 12:39:20 AM5/16/12
to tiddl...@googlegroups.com
I am wondering, if I use the viewer, how do I get it to display in the full area of my tiddlers. I have the following in [[StyleSheet]]. It was set that way so that other text would display with cool looking tiddlers with a blue background but when the viewer displays, it leaves a white space around it because of the padding. I need the padding for other tiddlers but not the viewer. How do I take the padding off if I am going to use the viewer? Anyone?
.tiddler {
background: [[ColorPalette::Background]];
border-right: 2px [[ColorPalette::TertiaryMid]] solid;
border-bottom: 2px [[ColorPalette::TertiaryMid]] solid; margin-top: 4em;
margin-bottom: 1em;
margin-left: 1em;
padding: 1em 2em 2em 1.5em;
}
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To post to this group, send email to tiddl...@googlegroups.com.
To unsubscribe from this group, send email to tiddlywiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.


Måns

unread,
May 16, 2012, 1:00:05 PM5/16/12
to TiddlyWiki
Hi Andrew

> I am wondering, if I use the viewer, how do I get it to display in the full area of my tiddlers.
Change iframe properties:
style="width:100%; height:500px;" frameborder="0"></iframe></html>

And/or change tiddler layout based on a tag:

[[StyleSheet]]

div[tags~="Wide"].tiddler {width: auto; margin: .6em -12em .5em 0;}
div[tags~="Wide"] .tagged {display:none;}
div[tags~="Wide"] .title {display:none;}
div[tags~="Wide"] #sidebar {display:none;}
div[tags~="Wide"] #mainMenu {display:none;}

(Not tested ...)

Good luck

Cheers Måns Mårtensson

Måns

unread,
May 16, 2012, 2:36:16 PM5/16/12
to TiddlyWiki
Hi again

> ...
> div[tags~="Wide"] #sidebar {display:none;}
> div[tags~="Wide"] #mainMenu {display:none;}
>
> (Not tested ...)

Sorry - it seems that you won't be able to hide id's like this.
You'll need http://mptw.tiddlyspot.com/#HideWhenPlugin or
http://www.TiddlyTools.com/#TaggedTemplateTweak
if you want to hide sidebars with a tag...

Cheers Måns Mårtensson

andrew.j.harrison84

unread,
May 16, 2012, 7:33:34 PM5/16/12
to tiddl...@googlegroups.com

Ok so I figured out that if I set the padding to a percentage, then I can apply a negative margin on the left and display width of 107 percent and the viewer fills the tiddler like I wanted but I just can't figure out what to do with the padding at the bottom of the tiddler that sticks out under the viewer. Also, I set the z-index value but when I transclude it, it seems to loose the value because it displays in front of my drop down menu but behind it when viewed from the viewer tiddler itself. Any ideas?

andrew.j.harrison84

unread,
May 18, 2012, 7:39:55 PM5/18/12
to tiddl...@googlegroups.com

Well, I found that I could remove the bottom padding from the css but now I have to put <br> at the end of every tiddler and it is quirky if the tiddler ends witj a table or anything hidden with /% and %/ but it is a small price to pay for an inline pdf viewer that fills the tiddler area almost completely. My only problem is because I am trying to transclude the frame using a variable and AliasPlugin and it does display but I cant figure out where it is getting it's z-index value from. I tried setting it in css on the frame in the viewer and it works there but when I transclude it, it displays in front of everything and I want to send it behind my top drop down menus. Anyone familiar with z-index and frames and transclusion with AliasPlugin?

andrew.j.harrison84

unread,
Jun 27, 2012, 7:52:21 PM6/27/12
to tiddl...@googlegroups.com

I finally ended up with both iframes and objects and to display my menus in front of them, I put an iframe shim in a tiddler and transclude that tiddler into my menu. It was a little trick with the search plugin im using but i used the div examples in pagetemplate for displaying tiddlers and it works there also. This transclusion thing is way cool. I'm now ready for tiddlywiki5 but I hope I can get it to run on ie7 somehow.

Robert Pollard

unread,
Jun 28, 2012, 12:26:38 PM6/28/12
to tiddl...@googlegroups.com
Friends

One easy way I have recently discovered for embedding pdf files in TiddlyWiki is to use the Google Docs Viewer - https://docs.google.com/viewer

On that page, you can enter the URL of any .pdf file - or .doc, .ppt etc. and generate a link to view the document in Google Docs along with corresponding embed code, that can then be dropped into TW bracketed by <html> .. </html>

Robert

On Wed, Jun 27, 2012 at 7:52 PM, andrew.j.harrison84 <andrew.j....@gmail.com> wrote:

I finally ended up with both iframes and objects and to display my menus in front of them, I put an iframe shim in a tiddler and transclude that tiddler into my menu. It was a little trick with the search plugin im using but i used the div examples in pagetemplate for displaying tiddlers and it works there also. This transclusion thing is way cool. I'm now ready for tiddlywiki5 but I hope I can get it to run on ie7 somehow.

--

Craig in Calgary

unread,
Jul 10, 2012, 11:47:40 AM7/10/12
to tiddl...@googlegroups.com

I finally ended up with both iframes and objects and to display my menus in front of them, I put an iframe shim in a tiddler and transclude that tiddler into my menu. It was a little trick with the search plugin im using but i used the div examples in pagetemplate for displaying tiddlers and it works there also.

Would you consider sharing your TW magic with the community? I learn much from taking apart the successful work of others. Besides, I haven't been able to get local PDFs to render in an iframe yet. Thanks.

Craig

Meta

unread,
Jul 11, 2012, 7:23:17 AM7/11/12
to tiddl...@googlegroups.com
I would also be interested to see this

Ulrik Stervbo

unread,
Apr 2, 2014, 5:00:01 AM4/2/14
to tiddl...@googlegroups.com
In case anyone else wanders in here. The solution seems to be:

<object data="test.pdf" type="application/pdf" width="100%" height="100%">
 
  <p>It appears you don't have a PDF plugin for this browser.
  No biggie... you can <a href="myfile.pdf">click here to
  download the PDF file.</a></p>
 
</object>

Cheers,
Ulrik
Reply all
Reply to author
Forward
0 new messages