How do I export adjustbox-parameters?

adjustbox has now keys for this kind of stuff. In your case use gstore totalheight=\somelengthregister to store the total height. If you need more dimension have a look at gstore sizes and other keys described in the packae manual in section 4.14 Store box content.

\documentclass{article}
\usepackage{adjustbox}
\newlength\mylength

\begin{document}

\begin{adjustbox}{width={\textwidth},totalheight={8cm},keepaspectratio,gstore totalheight=\mylength}
 ... some content ...
\end{adjustbox}

(In between is some text and a page break.) 

\begin{adjustbox}{totalheight=\mylength,keepaspectratio}
 ...other content...
\end{adjustbox}

\end{document}

Original answer

There are no key options yet to store the size of an adjustbox, but I was already thinking to add them. The value of \totalheight can only be used in keys which affect the size. These actually box the content and therefore update this length to have the correct value. You can however do the required boxing yourself using some small code added using the precode key, by using features of the collectbox package, which is internally used by adjustbox anyway. You need a length register which is assigned globally.

\documentclass{article}
\usepackage{etex}
\usepackage[etex=true,export]{adjustbox}
\newlength\mylength
\begin{document}

\begin{adjustbox}{width={\textwidth},totalheight={8cm},keepaspectratio,precode={\collectbox{\global\setlength\mylength{\totalheight}\BOXCONTENT}}}
  ... some content ...
\end{adjustbox}

(In between is some text and a page break.)

\begin{adjustbox}{totalheight=\mylength,keepaspectratio}
 ...other content...
\end{adjustbox}

\end{document}

If you need this more often then you can define a new key for this:

\documentclass{article}
\usepackage{etex}
\usepackage[etex=true,export]{adjustbox}
\newlength\mylength

\makeatletter
\define@key{adjbox}{settototalheight}[1]{%
    \Gin@esetsize
    \@tempswatrue
    \adjust@addcode{\@collectbox{\global#1=\totalheight\relax\BOXCONTENT}}{}%
}
\makeatother

\begin{document}

\begin{adjustbox}{width={\textwidth},totalheight={8cm},keepaspectratio,settototalheight=\mylength}
  ... some content ...
\end{adjustbox}

(In between is some text and a page break.)

\begin{adjustbox}{totalheight=\mylength,keepaspectratio}
 ...other content...
\end{adjustbox}

\end{document}

Note that you need to add the key at the very end, because the order is significant.


The only way I see is to set the first box in a storage bin and measure it

% in the preamble
\newsavebox{\stephenbox}
\newlength{\stephenlength}

% in the document
\sbox{\stephenbox}
  {\begin{adjustbox}{width={\textwidth},totalheight={8cm},keepaspectratio}
   ...some content ...
   \end{adjustbox}}%
\setlength{\stephenlength}{\ht\stephenbox}%
\addtolength{\stephenlength}{\dp\stephenbox}%
\usebox{\stephenbox}

some lines later

\begin{adjustbox}{totalheight=\stephenlength,keepaspectratio}
...other content...
\end{adjustbox}