latex3 / pdfresources

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

New field in hyperref (specific for pdf forms) #31

Closed gildasprevost closed 2 years ago

gildasprevost commented 2 years ago

image

u-fischer commented 2 years ago

I would need small (!) example pdf with such a field so that I can check how it is encoded.

gildasprevost commented 2 years ago

Yes of course! Exemple.pdf

u-fischer commented 2 years ago

It should be smaller. Remove all the other fields and the graphics. The example should only contain the one field for the image. And describe how you create it in adobe.

u-fischer commented 2 years ago

As I wrote here https://texnique.fr/osqa/questions/10834/formulaire-pdf-avec-image-modifiable this is only a button field with a javascript action. A simple version looks like this

\RequirePackage{pdfmanagement-testphase} % not needed with latex-dev
\DocumentMetadata{uncompress}
\documentclass{article}
\usepackage{l3pdffield-testphase}
\begin{document}
\ExplSyntaxOn
  \group_begin:
  \tl_set:Nn\l_tmpa_tl{event.target.buttonImportIcon();}
  \pdf_object_unnamed_write:nx{stream}{{}{\exp_not:o{\l_tmpa_tl}}}
  \pdfannot_dict_put:nnx{widget}{A}{<</S/JavaScript /JS~\pdf_object_ref_last:>>}
  \pdffield_pushbutton:n{name=bild,width=10cm,height=8cm,MK/TP=1}
  \group_end:
 \ExplSyntaxOff
\end{document}

Border, colors etc can be adjusted with the existing methods.

The same should be possible with the existing \PushButton field of hyperref.

gildasprevost commented 2 years ago

That's perfect, thank you very much for this solution!