latex3 / pdfresources

LaTeX PDF resource management
LaTeX Project Public License v1.3c
22 stars 5 forks source link

appareance rotated with dvips if document is in landscape #24

Closed u-fischer closed 2 years ago

u-fischer commented 2 years ago
\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata {uncompress}
\documentclass[landscape]{article}
\usepackage{l3pdffield-testphase}
\begin{document}
\special{papersize=\the\paperwidth,\the\paperheight}
test landscape
\ExplSyntaxOn
\pdffield_appearance:nn {pdffield/test/Yes}{Y}

\pdffield_appearance:nn {pdffield/test/Off}{W}

\pdffield_checkbox:n{name=test,width=5cm,height=3cm,appearance=pdffield/test}
\ExplSyntaxOff

\end{document}

gives

image

The main problem is that dvips is actually cheating when setting the paper size. The media box is portrait and it rotates it:

<</Type/Page/MediaBox [0 0 612 792] /Rotate 270 ....

One can avoid it

which is then used for the mediabox.

Related discussion on the texlive list: https://tug.org/pipermail/tex-live/2021-July/047291.html

agrahn commented 2 years ago

The most robust approach is perhaps replicating all existing paper format entries in config.ps with swapped paper width and height values. Otherwise, dvips automatically inserts the DSC comment %%Orientation: Landscape at the top of the PS output when it finds a matching Portrait paper format entry in config.ps. This cannot be undone by adding clever PostScript, it seems. Eventually, the DSC comment %%Orientation: Landscape signals to ps2pdf to add /Rotate 90 to the Page dictionary, with the implications Ulrike described.

u-fischer commented 2 years ago

dvips will probably change its behaviour in texlive 2022 here. So waiting for now.

u-fischer commented 2 years ago

looks ok in texlive 2022.