Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/2920ecc94a5c478aafb6 to your computer and use it in GitHub Desktop.
Save zr-tex8r/2920ecc94a5c478aafb6 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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