Using crop package with XeLaTeX

I have the following crop.cfg. Try that.

% crop.cfg for xetex - JK - 2006-06-07
% This attempts to persuade crop.sty to work with xetex

\@ifundefined{XeTeXversion}{}{
    %% Use the "pdftex" driver (i.e., \pdfpagewidth, \pdfpageheight) with XeTeX
    \def\CROP@reqdriver{pdftex}

    %% make crop.sty believe this is valid
    \@ifundefined{pdfoutput}{
      \newcount\pdfoutput \pdfoutput=1
    }{}
}

\endinput
%% End of file `crop.cfg'.

It is a problem with scrbook, with book the example works fine. In the end it boils down to the fact that (newer versions of) scrbook inserts a \special at \begin{document}. One can reproduce the problem with this code:

\documentclass{book}
\usepackage[paperwidth =10cm,paperheight=20cm]{geometry}
\AtBeginDocument{\special {papersize=\the \paperwidth ,\the \paperheight }}
\usepackage[a4,center,cam]{crop}
\usepackage{lipsum}

%\makeatletter\let\scr@ifdvioutput\@gobble \show\@begindocumenthook

\begin{document}
\lipsum
\lipsum
\end{document}

The code is inserted by scrbook with a \scr@ifdvioutput test, this explains why the problem disappears if one defines \pdfoutput and set it to 1. Imho the problem should be reported to the KOMA author.

Edit

A work around is to add another \special:

\documentclass{scrbook}
\usepackage[paperwidth =10cm,paperheight=20cm]{geometry}
\usepackage[a4,center,cam]{crop}
\AtBeginDocument{\special {papersize=\the \stockwidth ,\the \stockheight }}

\usepackage{lipsum}
\begin{document}
\lipsum
\lipsum
\end{document}

In July I posted this problem on the KOMA-Script Forum and was told that the new version of KOMA (3.18 and later) set pagesize=auto as a default. Using pagesize=false reverts to the old behaviour, which works correctly with the crop-package.