+
+% see http://osdir.com/ml/tex.xetex/2005-10/msg00003.html
+\newsavebox{\ximagebox}\newlength{\ximageheight}
+\newsavebox{\xglyphbox}\newlength{\xglyphheight}
+\newcommand{\xbox}[1]
+{\savebox{\ximagebox}{#1}\settoheight{\ximageheight}{\usebox {\ximagebox}}%
+\savebox{\xglyphbox}{\char32}\settoheight{\xglyphheight}{\usebox {\xglyphbox}}%
+\raisebox{\ximageheight}[0pt][0pt]{%\raisebox{-\xglyphheight}[0pt] [0pt]{%
+\makebox[0pt][l]{\usebox{\xglyphbox}}}%}%
+\usebox{\ximagebox}%
+\raisebox{0pt}[0pt][0pt]{\makebox[0pt][r]{\usebox{\xglyphbox}}}}
+
+\newcommand{\makecover}[2]{
+ \pdfpagewidth=#1
+ \pdfpageheight=#2
+
+ \thispagestyle{empty}
+ \newlength{\PictHOffset}
+ \newlength{\PictVOffset}
+ \setlength{\PictHOffset}{1in}
+ \addtolength{\PictHOffset}{\hoffset}
+ \addtolength{\PictHOffset}{\oddsidemargin}
+
+ \setlength{\PictVOffset}{1in}
+ \addtolength{\PictVOffset}{\voffset}
+ \addtolength{\PictVOffset}{\topmargin}
+ \addtolength{\PictVOffset}{\headheight}
+ \addtolength{\PictVOffset}{\headsep}
+ \addtolength{\PictVOffset}{\topskip}
+ \addtolength{\PictVOffset}{-\pdfpageheight}
+
+ \noindent\hspace*{-\PictHOffset}%
+ \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
+ \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.png}}}
+ \clearpage
+
+ \setlength{\pdfpagewidth}{210mm}
+ \setlength{\pdfpageheight}{297mm}
+}
+
+