242

Is it possible to embed animated GIFs in PDFs? And how might I go about such a thing? are there any dangers I should be aware of?

For some more details on why I think it's a good thing and how it helps feel free to see this post. I didn't think it was appropriately well-formed enough for SE.

As an example - I'd like to put this into a description of quicksort:

quicksort animation from wikipedia
(This animation is from wikimedia.)

Joe
  • 4,367
  • 7
  • 33
  • 52
  • 4
    [It's possible if you generate a PDF with LaTeX](http://tex.stackexchange.com/questions/5396/is-there-any-way-to-include-an-animated-gif-directly/5397#5397) but I think the gif is an external file – Stéphane Laurent Aug 25 '13 at 16:56
  • 58
    PDFs are really not just for "printing" only any more - they entirely replace the printed document with digital documents, so embedding animations would be a logical addition. This is a great question, I don't see why it's not a widely supported/used feature. – Demis May 12 '16 at 16:17
  • 21
    (Don't forget to credit Wikipedia for this image.) – Lithy Jan 22 '17 at 14:24
  • 1
    [This answer](https://tex.stackexchange.com/a/55623) (and no other) works for me on a modern (2017) NixOS with Okular. Even autostart is supported in presentation mode (contrary to some places where it's stated that it's not). – Ingo Blechschmidt Dec 17 '17 at 19:58
  • Another solution is looking for epub. – Nader Belal Dec 13 '20 at 10:32

8 Answers8

79

I haven't tested it but apparently you can add quicktime animations to a pdf (no idea why). So the solution would be to export the animated gif to quicktime and add it to the pdf.

Here the solution that apparently works:

  1. Open the GIF in Quicktime and save as MOV (Apparently it works with other formats too, you'll have to try it out).
  2. Insert the MOV into the PDF (with Adobe InDesign (make sure to set Object> Interactive> film options > Embed in PDF) - It should work with Adobe Acrobat Pro DC too: see link
  3. Save the PDF.

See this link (German)

Aki la
  • 351
  • 3
  • 17
estani
  • 24,254
  • 2
  • 93
  • 76
  • 21
    This is great! But is there a free solution to do the same thing? Adobe InDesign is >$300/year. Also it's SO policy to actually copy the answer into the post - the translated page says to do the following: 1) Open the GIF in Quicktime and save as MOV (I could only get that to work with an AVI). 2) Insert the MOV into the PDF with Adobe InDesign (make sure to set `Object> Interactive> film options > Embed in PDF` 3) Save the PDF. – Demis May 12 '16 at 17:05
  • 1
    I can confirm that embedding a MOV file in a PDF via InDesign works. But Quicktime on my iMac refuses to open GIF files. Can you give more details about that part... what version of Quicktime are you using? – peacetype Mar 27 '18 at 10:43
  • 2
    As well as MOV files, any multimedia that is H.264 compliant can be played in Adobe Reader 9 and later. That can include MPG and many other common formats. More here: https://helpx.adobe.com/acrobat/using/rich-media.html – Dan Roberts Apr 15 '19 at 05:35
  • 1
    Including an mp4 in a PDF requires the Flash Player and will not be supported in most PDF readers. See this answer for more details: https://graphicdesign.stackexchange.com/a/130211/3145 – Justin Putney Oct 10 '19 at 18:08
  • 2
    InDesign doesn't open or edit PDFs, so I'm not sure how to execute the instructions "Insert the MOV into the PDF with Adobe InDesign". When I try to open my PDF with InDesign I get an error "InDesign may not support the file format..." – ChaosFreak Jun 03 '20 at 18:30
54

I do it for beamer presentations,

provide tmp-0.png through tmp-34.png

\usepackage{animate}

\begin{frame}{Torque Generating Mechanism}
  \animategraphics[loop,controls,width=\linewidth]{12}{output/tmp-}{0}{34}
\end{frame}
ahmedyar
  • 541
  • 4
  • 2
  • 17
    This worked great for me. However, no Linux PDF reader I tried could view the animations. I could only get them to work in Adobe Reader. – remcycles Jul 27 '18 at 15:31
  • 2
    according to the documentation https://www.ctan.org/pkg/animate it works with Acrobat Reader, KDE Okular, PDF-XChange and Foxit Reader – LudvigH Jun 09 '22 at 08:57
17

You can use Tikz/pgfplots for creating animations in beamer. http://www.texample.net/tikz/examples/tag/animations/

Moksher
  • 171
  • 1
  • 3
17

It's not really possible. You could, but if you're going to it would be useless without appropriate plugins. You'd be better using some other form. PDF's are used to have a consolidated output to printers and the screen, so animations won't work without other resources, and then it's not really a PDF.

CSturgess
  • 1,547
  • 2
  • 13
  • 29
  • 4
    Although it is true that GIF will not work "as is" inside a PDF, you can actually create animations using Javascript, but very few readers will support it. – yms Jan 26 '12 at 14:20
  • 27
    PDFs may have been originally made for physical printing, but have now completely taken the place of printed documents - they are the de-facto digital document, so it makes perfect sense that we should allow them to embed animations. – Demis May 12 '16 at 17:09
  • 1
    @Demis, there is no we in PDF, only Adobe (the company) – Nader Belal Dec 13 '20 at 10:28
  • 1
    @Nader that's actually a good point. Adobe says PDF is an "open standard" by ISO - not sure just how "open: though. https://acrobat.adobe.com/us/en/acrobat/about-adobe-pdf.html Also the site says PDF can contain video, maybe that's new. – Demis Dec 16 '20 at 05:24
  • @Demis, adding video to PDF's isn't that new ... and the only way in the past to add animated pics was by using (better said forcing) users to convert it to Flash ... Buy now that Adobe killed Flash, how the hell are we going to add animated Gif's and not videos !!!??? – Nader Belal Dec 17 '20 at 10:52
  • Since embedded video is supported, perhaps it would be possible to convert a GIF to a similarly small-sized video (indexed colors, small pixel size etc.)? – Demis Dec 18 '20 at 15:12
9

Another possibility is LaTeX + animate package. You will need to provide the individual frames making the animation. The resulting pdf does NOT require any plugin, the animation is shown in Adobe reader

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
Massi
  • 91
  • 1
  • 1
8

Maybe use LaTeX and try something like this

\documentclass[a4paper]{article}
\usepackage[3D]{movie15}
\usepackage{hyperref}
\begin{document}
\includemovie[
    poster,
    toolbar, 
    3Daac=60.000000, 3Droll=0.000000, 3Dc2c=0.000000 2.483000 0.000000,     3Droo=2.483000, 3Dcoo=0.000000 0.000000 0.000000,
    3Dlights=CAD,
]{\linewidth}{\linewidth}{Bob.u3d}
\end{document}

where Bob3d.u3d is a sample virtual reality file I had. This works (or did) for movies, and I expect it might work for gifs too.

L. F.
  • 19,445
  • 8
  • 48
  • 82
John Starrett
  • 81
  • 1
  • 2
3

I just had to figure this out for a client presentation and found a work around to having the GIF play a few times by making a fake loop.

  • Open the Gif in Photoshop
  • View the timeline
  • Select all the instances and duplicate them (I did it 10 times)
  • Export as a MP4
  • Open up your PDF and go to TOOLS> RICH MEDIA>ADD VIDEO> then place the video of your gif where you would want it
  • A window comes up, be sure to click on SHOW ADVANCED OPTIONS
  • Choose your file and right underneath select ENABLE WHEN CONTENT IS VISIBLE

Hope this helps.

Celine
  • 31
  • 1
1

Having the ability to add small animations to a PDF (portable document format, independent of application software, hardware, and operating systems) would make it the perfect solution for making extremely useful user guides. Some text, some images, and some animations/videos, all in one file that can be read by anybody on any computer.

As of acrobat pro version x, a gif can be added under Tools > Insert from File. But the gif wont play, it only shows the first image.

Henry
  • 11
  • 2