# Using animate package, with an animation set to loop, is it possible to set the frame that will be physically printed?

I have successfully managed to integrate an animation using several .png files into my pdf. However, I have noticed that when I tried to print the pdf, the frame printed was the one shown at the exact moment I pressed the print button. I was using Adobe Acrobat Pro when trying this.

I am aware that you can set the frame to be displayed if the pdf is opened with a viewer that does not support animations, but it appears to have no influence in my case.

My question is thus : is there a way to make sure that the frame printed with a pdf viewer that supports animations is the same one as the one displayed when openend with a basic viewer ?

This behavior can be repeated with this code:

\documentclass{article}

\usepackage{animate}
\usepackage{tikz}

\begin{document}

\animategraphics[controls=none,width=1in,loop,autoplay,poster=5]{10}{example-image-a4-numbered}{}{}

\end{document}

• Welcome to TeX.SE! Oct 20, 2021 at 15:27
• @Mensch Thanks ! Oct 20, 2021 at 15:35
• I typeset your example and loaded it in Chrome (Its PDF viewer does not support animations). Chrome shows and prints the frame with a "6" in it, which is exactly what I expect. The same with Evince. Maybe, I didn't understand your question correctly? Oct 20, 2021 at 16:04
• @AlexG Yes, their question is about actual printing from an animation supporting PDF viewer. My best answer would be to actually use a non-supporting animation viewer when wanting to print, or to produce a PDF dedicated to printing without animation (which is a good practice anyway for a lot of printers), but this might not be compatible with your use-case. Also, I don’t know if an existing solution would apply to all animation-enabled viewers… Oct 20, 2021 at 18:17
• @Archange yes that's exactly what I meant. My goal is to make sure that anyone printing my pdf regardless of the pdf viewer used will have the same printed document in the end. In the mean time I'll probably do as you said: have two versions of the pdf. Oct 21, 2021 at 7:39

This can be achieved with a document action that is triggered when the document is going to be printed. Making use of package animate's JavaScript interface, we ensure that the animation is paused and reset to the desired frame upon printing. For addressing a specific animation, we need to give it a unique label, label=1 in the present case:

Using an up-to-date TeX installation, such as TeXLive-2021:

\RequirePackage{pdfmanagement-testphase} %making entries into PDF Catalog

\documentclass{article}

\usepackage{animate}
\usepackage{graphicx}

\ExplSyntaxOn
%additional document actions (AA) --> trigger "Will Print" (WP)
>>}
\ExplSyntaxOff

\begin{document}

\animategraphics[label=1,controls=none,width=1in,loop,autoplay,poster=5]{10}{example-image-a4-numbered}{}{}

\end{document}


Or alternatively with engine-specific low level command \pdfcatalog (not future-save):

\documentclass{article}

\usepackage{animate}
\usepackage{graphicx}

\pdfcatalog{
/AA <<
/WP <<
>>
>>
}

\begin{document}

\animategraphics[label=1,controls=none,width=1in,loop,autoplay,poster=5]{10}{example-image-a4-numbered}{}{}

\end{document}


Tested with AR DC. Printing the document with the animation running always prints the 5th (zero-based) animation frame, displaying a "6", on paper.

• Thank you for the answer, sadly I can't seem to make it work. I tried to run your code on Overleaf and I have an error message ("LaTeX Error: File `pdfmanagement-testphase.sty' not found."). I also tried with an offline compiler which managed to output a pdf but the initial issue remains :( Oct 21, 2021 at 13:53
• You need an up-to-date TeX installation, such as TeXLive-2021, or MiKTeX. Oct 21, 2021 at 14:00
• @RaphM Answer edited. Both versions tested with Acrobat Reader DC. Oct 21, 2021 at 14:09