[Tex/LaTex] pdfpages package and layoutsize (geometry package)

geometrypaper-sizepdfpages

I tried to include a PDF page using the pdfpages package — this works well for a standard case, f.e. (t.pdf is the first page of the PGF manual):

\documentclass{scrartcl}
\usepackage{geometry}
\geometry{papersize={155mm,220mm}}
\usepackage{pdfpages}
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]
\includepdf{t.pdf}
\end{document}

This code produces the following output:

Output of the first MWE.

In my case, my printer needs an additional trimming edge, since I use full-page images. For all other publications (there was no need to include other PDF files) I used the very comfortable option layoutsize in combination with papersize of the geometry package. Unfortunately, if I use this option, the pdfpages package does ignore it (exaggerated by intention):

\documentclass{scrartcl}
\usepackage{geometry}
\geometry{papersize={200mm,300mm}, layoutsize={155mm,220mm}}
\usepackage{pdfpages}
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]
\includepdf{t.pdf}
\end{document}

This produces the following output:

Output of the second MWE

As you can see, the layout of the text content is untouched, but the included PDF is scaled to the paper size, not to the layout size. Is there a possibility to include a PDF file while respecting the layout size given by the geometry package?

Thank you for your help in advance.

Edit:
I have forgotten to take the layoutoffset option of the geometry package into account in my question. A solution should not only respect the given layout size, but also its offset specification.

\documentclass{scrartcl}
\usepackage{geometry}
\geometry{papersize={200mm,300mm}, layoutsize={155mm,220mm}, layoutoffset={10mm,5mm}}
\usepackage{pdfpages}
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]
\includepdf{t.pdf}
\end{document}

Best Answer

You can pass the layout width and height (of course you can use the figures you know, but this is independent from them):

\makeatletter
\includepdf[
  pages=1,
  width=\Gm@layoutwidth,
  height=\Gm@layoutheight,
  offset={\dimexpr(\Gm@layoutwidth-\paperwidth)/2\relax}
         {\dimexpr(\paperheight-\Gm@layoutheight)/2\relax},
  keepaspectratio
  ]{pgfmanual.pdf}
\makeatother

Of course it won't be perfect unless the proportions of the layout dimension are the same as that of the PDF you're including.