Background: All PDF has a MediaBox that describes the page size, for each page. This is found in the PDF as (for example, US letter) the text string /MediaBox [0 0 612 792] where the numbers are "big points."
It is easy to calculate what the MediaBox should be, based on page dimensions. MWE:
% Must work with pdflatex. Specifically pdflatex.
\documentclass[letterpaper]{memoir} % All pages same size.
\usepackage{pgf}
\newcommand{\whatTexUsesForMBwidth}{That is the width question!}
\newcommand{\whatTexUsesForMBheight}{That is the height question!}
% First is where the result is stored, second is the input.
% Input TeX pt, Result in bp to 0.1 no units.
\newcommand{\getbigpoints}[2]{
\pgfmathsetmacro#1{round(0.99626401*(#2+0.005))}
}
\newcommand\getMediaBoxWidth{
\getbigpoints{\myMBW}{\stockwidth}
}
\newcommand\getMediaBoxHeight{
\getbigpoints{\myMBH}{\stockheight}
}
\getMediaBoxWidth
\getMediaBoxHeight
\begin{document}
My calculated MediaBox width = \myMBW\par
My calculated MediaBox height = \myMBH\par
TeX internal MediaBox width = \whatTexUsesForMBwidth\par
TeX internal MediaBox height = \whatTexUsesForMBheight\par
\end{document}
OUTPUT:
My calculated MediaBox width = 612.0
My calculated MediaBox height = 792.0
TeX internal MediaBox width = That is the width question!
TeX internal MediaBox height = That is the height question!
Now, I can always inspect the PDF in an editor, and read the MediaBox directly. But what I want to do is learn the MediaBox string while TeX is running, so that I can use the string within the TeX document.
Why I want to do this: For compliance purposes, my documents require /TrimBox, which in my case is exactly /MediaBox. I can calculate the values and write the string into the PDF without problem using TeX with the correct packages (and it is valid, according to Adobe Acrobat Pro 9). But that's because I am currently using a standard page size. If I ever need to use an exotic page size, there is the risk that my calculation will differ from the TeX internal values by a fraction of a point. That could cause an undetected error. However, if I knew the actual /MediaBox string, I could merely copy it to /TrimBox without need of calculation.
I have already set up a mock landing strip and prayed for Cargo, without result.


3is the value of\pdfdecimaldigits. – Heiko Oberdiek May 17 '15 at 23:19\pdfdecimaldigitsis limited to 0 to 4, when the values for theMediaBoxare calculated. – Heiko Oberdiek May 18 '15 at 01:05expl3– egreg May 18 '15 at 14:43\pdfdecimaldigits;xdvipdfmxuses a default of 2, and the parameter cannot be specified nor inspected within XeTeX, as far as I know. – egreg Dec 19 '15 at 14:03\getTrimBoxout of this answer and make it puttable inside something like\pdfpageattr\expandafter{\getTrimBox}Or should i ask different question? – Leonid Dec 19 '15 at 19:48