# Is it possible to embed a scrollable frame inside a PDF?

(This is an end-of-year crazy question)

Is it possible to embed a (scrollable) frame or a PDF inside a PDF? If so, how to do it in (pdf)LaTeX?

This is something pretty common in HTML (see for example http://www.echoecho.com/htmlframes01.htm). Here it is a webpage with PDF frames https://www.cs.tut.fi/~jkorpela/html/iframe-pdf.html

Here it is a fake screenshot so you get the idea.

Portable and non-portable (e.g. only-Acrobat) answers are welcomed.

Example of a down arrow below a frame. The up arrow can be on top of the frame and the triangles point up.

• Related but not the same thing: tex.stackexchange.com/q/96260/1871 – alfC Dec 17 '15 at 12:23
• As far as I can see, the only "off the shelf" scrollable element would be a multiline text field. However, to make it scrollable, you can not make it read-only. Another possbility would be placing a button field, and make the scrollable PDF the icon. You then add scrolling buttons and appropriate JavaScript code to change the position of the icon in the field (see button field properties in Acrobat). – Max Wyss Dec 17 '15 at 12:25
• The closest to your requirements that you can get is probably this: tex.stackexchange.com/a/211010 – AlexG Dec 17 '15 at 12:29

Vertical scrolling based on the animate package; definition of command \smoothScroll taken from an earlier post with slight modifications.

As an example document, we take lppl.pdf from TEXMF/doc/latex/base/lppl.pdf, the pages somewhat trimmed.

Update with suggestions incorporated:

Start auto-scroll by clicking on the "widget", pause auto-scroll on mouse-down in the "widget" (and moving the mouse out, while keeping it pressed).

The buttons above and below the "widget" step through the document on mouse click.

[Shift]+click on the buttons rewinds to the top or jumps to the bottom of the document.

\documentclass[a5paper]{scrartcl}

\usepackage{multido}
\usepackage{graphicx}
\usepackage{MnSymbol} % \triangle, \triangledown
\usepackage{animate}
\usepackage{media9}   % \mediabutton
\usepackage{xsavebox} % \xsbox{<xsbox id>}{<content>} , \the<xsbox id>

%%%%%%% docToBox  %%%%%%%%
\newcommand\docToBox[3]{%
% #1 <file name (PDF)>
% #2 <left> <bot> <right> <top> % trim pages by given amounts (PS points)
% #3 <boxnum>
\pdfximage{#1}%  just for counting pages
\multido{\i=1+1}{\pdflastximagepages}{%
\global\setbox#3=\vbox{%
\box#3%
\hbox to \textwidth{\includegraphics[page=\i,trim=#2,clip,width=\textwidth]{#1}}%
}%
}%
}
%%%%%%% /docToBox %%%%%%%%

%%%%%%% smoothScroll %%%%%
\newcommand\smoothScroll[5][]{%
% [#1] autoplay, controls, ... (see: texdoc animate)
% #2 <boxnum>
% #3 <viewport height>
% #4 <steps>
% #5 <steps per sec> while playing; >25 doesn't make sense
\edef\mywd{\the\wd#2}%
\edef\myht{\the\ht#2}%
\edef\mytht{\the\dimexpr\ht#2+\dp#2\relax}%
\xsbox{XFormOfDoc}{\usebox{#2}}% distill box into re-usable PDF XObject
\edef\portht{\the\dimexpr#3\relax}%
\begin{animateinline}[#1,width=\mywd,height=\portht]{#5}%
\multiframe{#4}{
dRaiseLen=\the\dimexpr-\myht+\portht\relax+\the\dimexpr(\mytht-\portht)/#4\relax
}{%
\begin{minipage}[b][\portht][b]{\mywd}%
\raisebox{\dRaiseLen}[0pt][0pt]{\theXFormOfDoc}%
\end{minipage}%
}%
\end{animateinline}%
}
%%%%%%% /smoothScroll %%%%%

\begin{document}\Huge

\newbox\lipsumbox
%load the document with trims into save-box
\docToBox{lppl.pdf}{131 110 115 121}{\lipsumbox}
\edef\boxwidth{\the\wd\lipsumbox}%

\noindent Before you consider using \LaTeX, read the fine-print:\\
\noindent\mediabutton[
jsaction={
}
]{\fboxsep=0pt\framebox[\boxwidth][c]{\tiny\strut$\triangle\triangle\triangle$}}
%the scrolling widget
\noindent{\fboxsep=-\fboxrule\fbox{\smoothScroll[label=lppl]{\lipsumbox}{0.79\textheight}{512}{25}}}
\vskip -0.8\baselineskip
\noindent\mediabutton[
jsaction={
]{\fboxsep=0pt\framebox[\boxwidth][c]{\tiny\strut$\triangledown\triangledown\triangledown$}}%

• Yes, I mean if the buttons can be arranged vertical and on the side. Or perhaps have a short elongated button below the frame [ vvv ] and one on the top [ ^^^ ]. See my edit at end of the post for an example image. – alfC Dec 18 '15 at 9:21