1

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 ?

Thanks in advance !

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}
6
  • 1
    Welcome to TeX.SE!
    – Mensch
    Oct 20, 2021 at 15:27
  • 1
    @Mensch Thanks !
    – RaphM
    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?
    – AlexG
    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…
    – Archange
    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.
    – RaphM
    Oct 21, 2021 at 7:39

1 Answer 1

2

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
\DeclareDocumentMetadata{}

\documentclass{article}

\usepackage{animate}
\usepackage{graphicx}

\ExplSyntaxOn
%additional document actions (AA) --> trigger "Will Print" (WP)
\pdfmanagement_add:nnx{Catalog/AA}{WP}{<<
  /S/JavaScript/JS~(anim["1"].pause();anim["1"].frameNum=5;)
>>}
\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 <<
      /S/JavaScript/JS (anim["1"].pause();anim["1"].frameNum=5;)
    >>
  >>
}

\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.

3
  • 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 :(
    – RaphM
    Oct 21, 2021 at 13:53
  • You need an up-to-date TeX installation, such as TeXLive-2021, or MiKTeX.
    – AlexG
    Oct 21, 2021 at 14:00
  • @RaphM Answer edited. Both versions tested with Acrobat Reader DC.
    – AlexG
    Oct 21, 2021 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.