# Trim Box not working in XeTeX

Here my requirement is set trim box for creating PDF using xetex, but the PDF not generated with trim box. Please provide a solution to fix this, here my TeX code

MWE:

\documentclass{book}
\usepackage{atbegshi}

% MediaBox can be fixed like so:
\makeatletter
\special{pdf:put @thispage <<
/MediaBox [0 0 612.00000 792.00000]
>>}
}}

% other boxes

\special{pdf:put @pages <<
/BleedBox [81.0 63.0 531.0 729.0]
/CropBox [0 0 612.00000 792.00000]
/TrimBox [90.0 72.0 522.0 720.0]
>>}
\makeatother

\begin{document}
Between 200BC and 100BC, during the Han Dynasty, the Chinese used matrix-type methods with the text \textit{Nine chapters on the mathematical art}. There was further development, but it was not until 1683 when the idea of a determinant appeared in Japan when Seki wrote \textit{Method of solving the dissimulated problems}. This used matrix methods in tables in the same way as the earlier work of the Chinese. Ten years later the determinant first appeared in Europe in the work of Leibniz. The word determinant was first introduced by Gauss in 1801 while discussing quadratic forms, but Cauchy in 1812 used determinant in the modern sense.

Between 200BC and 100BC, during the Han Dynasty, the Chinese used matrix-type methods with the text \textit{Nine chapters on the mathematical art}. There was further development, but it was not until 1683 when the idea of a determinant appeared in Japan when Seki wrote \textit{Method of solving the dissimulated problems}. This used matrix methods in tables in the same way as the earlier work of the Chinese. Ten years later the determinant first appeared in Europe in the work of Leibniz. The word determinant was first introduced by Gauss in 1801 while discussing quadratic forms, but Cauchy in 1812 used determinant in the modern sense.
\end{document}

• Why are you putting the trimbox into @pages instead of as /Mediabox into @thispage? – Ulrike Fischer Apr 5 at 14:57
• not sure if it was ever added see old answer tex.stackexchange.com/a/49093/170109 however depends on how you look at it but if crop box is same as media box trim is outside both according to acrobatusers.com/tutorials/finding-page-boundaries – user170109 Apr 5 at 15:23
• Here I want page layout for my PDF with trim, bleed and crop box. Here I attached image and highlight my requirement for your reference – Rajesh Kumar Apr 8 at 7:54

According to the PDF Specification, only the MediaBox and CropBox are inheritable.

Also, the default value of CropBox is the value of MediaBox, so you don't have to specify it in your case.

This means, you should put the MediaBox into the @pages object and the BleedBox and TrimBox into the @thispage object.

\documentclass{book}
\usepackage{lipsum}
\usepackage{atbegshi}

\special{pdf:put @pages <<
/MediaBox [0 0 612.00000 792.00000]
>>}

\AtBeginShipout{%