# Rotate all pages of the output PDF by 90 degrees

How do I get XeLaTeX to output all pages of the PDF by 90 degrees? The content should be rotated, too. This is less of a typesetting, and more of a PDF output question. I am using KOMA-Script with XeLaTeX.

To add some detail to the question, consider the following MWE:

\documentclass{scrartcl}
\usepackage{fontspec}
\usepackage{pdflscape}

\begin{document}
not rotated
\begin{landscape}
rotated
\end{landscape}
\end{document}


The typesetting is just how I want it. However, only the landscaped page is rotated. If I change pdflscape to lscape, then no page is rotated. How do get to rotate all pages in the output?

I am aware that I could use a tool like qpdf afterwards, but I would like to do it directly with XeLaTeX.

Typing the question out, I have found a solution by looking at the source of pdflscape, based on this answer about setting the rotation attribute with XeLaTeX and the manual of the dvipdfm driver (however I am not sure if this is the correct documentation for \special in XeLaTeX):

\documentclass{scrartcl}
\usepackage{fontspec}
\usepackage{lscape}
\special{pdf: put @pages << /Rotate 90 >>}

\begin{document}
not rotated
\begin{landscape}
rotated
\end{landscape}
\end{document}


The lscape package will not rotate any PDF pages, and the \special command rotates all of them.