Scaling shown pdfs?

144 views
Skip to first unread message

Petri M.

unread,
Feb 24, 2022, 6:07:20 AM2/24/22
to TiddlyWiki

I just added a pdf as an external image with _canonical_uri and everything works fine, but the pdf is quite large and it is very hard to read from the small pdf viewer because I use two column system. I thought about opening the tiddler in an external window but for some reason the pdf only get smaller and is entirely impossible to read.

Can I scale the pdf zoom and perhaps put it in landscape mode or something? I guess it is being handled by adobe pdf reader. Or maybe fix the opening as a new window?

I mean look at this, can't really do anything with this:

Screenshot 2022-02-24 130417.png

Sergio Rolim

unread,
Feb 24, 2022, 4:46:14 PM2/24/22
to TiddlyWiki

Sergio Rolim

unread,
Feb 25, 2022, 7:24:24 AM2/25/22
to TiddlyWiki

<object data="./path/to/filename.pdf" type="application/pdf" width="100%" height="540px"></object>

Petri M.

unread,
Feb 25, 2022, 7:36:52 AM2/25/22
to TiddlyWiki
Works great! Thank you!

-Petri

Eric Shulman

unread,
Feb 25, 2022, 8:20:46 AM2/25/22
to TiddlyWiki
Here's a little macro that I've been working on.  It handles both internally-stored (base64 encoded data URIs) and externally-stored (using _canonical_uri) PDFs.  It uses URL parameters to omit the default PDF viewer's toolbar, and can also automatically scroll to a specified page within the PDF:
```
\define PDF(tid,page,suffix)
<$vars hdr={{{ [[data:]] [[$tid$]get[type]] [[;base64,]] +[join[]] }}}>
<$vars arg="#toolbar=0&page=$page$&$suffix$">
<$vars src={{{ [[$tid$]get[_canonical_uri]] ~[[$tid$]get[text]addprefix<hdr>] [<arg>] +[join[]] }}}>
<$vars sty="border:0;width:100%;height:100%;">
<object type="application/pdf" data=<<src>> style=<<sty>>>
   <embed type="application/pdf" src=<<src>> style=<<sty>>/>
</object>
\end
```
To set the desired display size, enclose the `<<PDF>>` macro inside a `<div>` using a style attribute to specify the width and height.

For example, to show a regular page size, you can write:
`<div style="width:8.5in;height:11in;"><<PDF "SomeTiddler">></div>`
or, to scale it down to half size:
`<div style="width:4.25in;height:5.5in;"><<PDF "SomeTiddler">></div>`
or, as a thumbnail:
`<div style="width:4.25em;height:5.5em;"><<PDF "SomeTiddler">></div>`

Here's some documentation from Adobe about using URL parameters for opening PDF files:

enjoy,
-e

A Gloom

unread,
Feb 26, 2022, 8:32:06 PM2/26/22
to TiddlyWiki
Very nice Eric.  Thank you!  Especially that Adobe link, very useful.
Reply all
Reply to author
Forward
0 new messages