Instantly share code, notes, and snippets.

@zr-tex8r /image.tex
Last active Aug 29, 2015

Embed
What would you like to do?
LaTeX: What kind of bounding boxes do dvipdfmx use in including PDF image files?
% This is a pdfLaTeX document.
\documentclass{article}
% The papersize is set to 250bp x 250bp, which will
% make the MediaBox equal [0 0 250 250].
\usepackage[papersize=250bp,margin=0pt,noheadfoot]{geometry}
\pagestyle{empty}
% No compression; PDF version still might be 1.5.
\pdfcompresslevel=0
\pdfobjcompresslevel=0
\setlength{\parindent}{0pt}
\begin{document}
\pdfpageattr{%
% Enable or disable each of the following lines.
/BleedBox [0 0 200 200]
/CropBox [0 0 150 150]
/TrimBox [0 0 100 100]
/ArtBox [0 0 50 50]
}
\vspace*{\fill}
\setlength{\unitlength}{1bp}\Large
\begin{picture}(50,50)
\put( 0, 0){\makebox(0,0)[lb]{O}}
\put( 50, 50){\makebox(0,0)[rt]{A}}
\put(100,100){\makebox(0,0)[rt]{T}}
\put(150,150){\makebox(0,0)[rt]{C}}
\put(200,200){\makebox(0,0)[rt]{B}}
\put(250,250){\makebox(0,0)[rt]{M}}
\end{picture}
\end{document}
% This is a plain TeX document containing a dvipdfmx special.
Here\vskip 100pt
% Include a PDF image without giving bbox values.
\special{pdf:epdf clip 1 width 100pt (image.pdf)}%
\bye
% This is a pdfLaTeX document.
\documentclass{article}
\usepackage[papersize={900pt,300pt},scale=0.9]{geometry}
\usepackage{graphicx}
\begin{document}\noindent
% THe 'pagebox' option specifies which box should be used.
\includegraphics[pagebox=mediabox]{image.pdf}
\includegraphics[pagebox=bleedbox]{image.pdf}
\includegraphics[pagebox=cropbox]{image.pdf}
\includegraphics[pagebox=trimbox]{image.pdf}
\includegraphics[pagebox=artbox]{image.pdf}
\end{document}
@zr-tex8r

This comment has been minimized.

Owner

zr-tex8r commented Jun 21, 2014

pdflatex image.tex

で5つのboxが全て異なるPDF文書が得られる。
(なお MediaBox の値は geometry で与えた用紙サイズの通りで 0 0 250 250 である。)

この後、

tex test.tex
dvipdfmx test.dvi

として得られる test.pdf を見ると、dvipdfmx がどの box を用いたか判断できる。
また、

extractbb image.pdf

で extractbb がどの box を用いたかが判断できる。

※ちなみに、image.pdf を Adobe Reader や SumatraPDF 等で開くと、CropBox の中のみが表示される。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment