latex3 / pdfresources

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

Content clipping during XForm generation with dvips and ps2pdf #25

Closed agrahn closed 2 years ago

agrahn commented 2 years ago

When going the dvips route, large content to be stored as XForms, such as graphics files, may be clipped during PS to PDF conversion. The initial clipping path of a PS file is identical with the edges of the page device. (It might be further shortened by user code.) When content is placed between the BP and EP pdfmarks at a given location on the page, any portion that extends beyond the clipping path is missing from the resulting XForm object.

Consider this example input:

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{backend=dvips,uncompress,pdfversion=2.0}

\documentclass{article}

\usepackage{l3pdffield-testphase}
\usepackage{graphicx}

\ExplSyntaxOn

\begin{document}\parindent=0pt
Content~clipping~should~be~avoided~during~XForm~generation:%
\pdfxform_new:nnn{img}{}{\includegraphics{example-image}}\par
\pdfxform_use:n{img}\par

Push~button:\pdfannot_dict_put:nnn {widget}{A}{<</S/Named /N/LastPage>>}
\pdffield_pushbutton:n
  {name=my/go,width=4cm,height=3cm,appearance=img,caption=GO~TO~LAST~PAGE,rollover-caption=click~me!}

\newpage
\Huge The~End.
\end{document}

The PS output opened in gv or in another PS viewer shows the placement of the content to be stored as an XForm object. Some part extends beyond the right paper edge and is finally missing in the PDF output.

PS output:

xformtest-0

The attached file l3backend-testphase-dvips.def.zip addresses this issue by aligning the content with the upper-left page corner. This allows the whole clipping path of the page device to be used for XForm generation.

u-fischer commented 2 years ago

thanks! I will look at it tomorrow.

u-fischer commented 2 years ago

Sorry I seem to have forgotten that. I now added the code to the newest version and uploaded to ctan.