[XeTeX] Generating cropped PDF graphics file
R (Chandra) Chandrasekhar
chandra at ee.uwa.edu.au
Thu Apr 17 09:14:55 CEST 2008
Ross Moore wrote:
> This works just fine for me, with XeLaTeX
> (XeTeX v. 0.997 )
>
> \documentclass[dvipdfmx,12pt]{article}
> \usepackage{graphicx}
> \newbox\shipoutbox
> \begin{document}
> \setbox\shipoutbox=\hbox{%
> The quick brown fox jumps over the lazy dog.
> }%
> \setbox0=\vbox{%
> \kern-1truein
> \hbox{%
> \kern-1truein
> \framebox{\box\shipoutbox}%
> \kern1truein
> }\kern1truein
> }%
> \dimen0\ht0\advance\dimen0\dp0
> \pdfpageheight\dimen0
> \pdfpagewidth\wd0
> \shipout\box0
> \end{document}
Thank you once more.
I needed to remove the dvipdfmx global option on my system and then it ran just
fine.
> And so does the following:
>
> \documentclass[10pt,a4paper,onecolumn]{article}%
> \usepackage[nomath]{fontspec}
> \usepackage{xunicode}
> \usepackage{xltxtra}
> \usepackage[margin=25mm]{geometry}
>
> \usepackage[cmyk,xetex]{xcolor}
> \newbox\shipoutbox
> \newlength{\mlength}
> \newsavebox{\logobox}
> %\setmainfont{Minion Pro} % I don't have this font
> \setmainfont{Lucida Grande}%
>
> \definecolor[named]{lettercolor}{cmyk}{0, 0.75, 0.75, 0.50}
> \definecolor[named]{linecolor}{cmyk}{0.5, 0.1, 0.5, 0.25}%
>
> \begin{document}
> \settowidth{\mlength}{\Huge{M}}
> \sbox{\logobox}{%
> \begin{tabular}{c}
> \color{linecolor}\rule[0.0em]{\mlength}{2pt}\\
> \color{lettercolor}\Huge{M}\\[-6pt]
> \color{linecolor}\rule[0.0em]{\mlength}{2pt}
> \end{tabular}%
> }%
> \begingroup
> \setbox0=\vbox{\kern-1truein
> \hbox{\kern-1truein
> \usebox{\logobox}%<--- contents goes here
> \kern1 truein}%
> \kern1truein}%
> \dimen0\ht0 \advance\dimen0\dp0
> \pdfpageheight\dimen0
> \pdfpagewidth\wd0
> \shipout\box0
> \endgroup
> \usebox{\logobox}% see it on the page also
> \end{document}
The above worked as well after I changed [nomath] to [no-math] on my system.
The "LaTeX Companion" (2ed) on page 841 advises
"It is important that you exclusively use the LaTeX constructs described below,
rather than the lower-level TeX commands."
This was behind my previous question on LaTeX equivalents for TeX commands. Now
that you have demonstrated the power of the direct TeX commands, I am encouraged
to experiment modularizing the above into a standalone package.
> All the package solutions do basically this, plus often
> a lot more stuff which is frequently quite redundant.
> You don't need to know the size in advance; and parameters
> such as margins, topskip, h-offset, v-offset, baselines
> etc. are completely irrelevant.
It is very useful to know this. Thanks.
Chandra
More information about the XeTeX
mailing list