typst
typst copied to clipboard
PDF file attachments
Description
I'd like to be able to create PDF attachments.
(Screenshot from https://helpx.adobe.com/acrobat/using/links-attachments-pdfs.html#)
Use Case
It's very convenient to add file attachments to the PDF itself. Not only Acrobat Reader, but also many open source readers support it.
Here is an example code in LaTeX that shows how to embed the file in the list of embedded files, set the flags and also reuse the embedded binary in a File Attachement Annotation. Maybe it helps the person who wants to implement this.
\pdfcompresslevel=0
\pdfobjcompresslevel=0
\documentclass[a4paper]{article}
\usepackage{embedfile}
\usepackage{attachfile2}
\expandafter\xdef\csname theatfi@flags\endcsname{704}
\newcommand{\clickablefile}[2]{%
\embedfile[ucfilespec={#1}]{#1}%
%\expandafter\xdef\csname atfi@embed@file@#1\endcsname{\the\numexpr\pdflastobj-1}%
\expandafter\xdef\csname atfi@fileobj@#1\endcsname{\the\numexpr\pdflastobj-1}%
\textattachfile[ucfilespec={#1},icon={Paperclip}]{#1}{#2}%
}
\begin{document}
\clickablefile{test.txt}{Double click to export the file}
\end{document}
This seems like a good-contribution, the relevant sections in the PDF 1.7 spec are 12.5.6.15 and 7.11.4, these features would have to be upstreamed into pdf-wirter before typst can support this.
... these features would have to be upstreamed into pdf-wirter before typst can support this.
As far as I can tell, pdf-writer
has support for this already: https://github.com/typst/pdf-writer/commit/ba040ace792d57a2e57e4973a38abb1561cdc057