Embedding a file is fairly easy using LaTeX (see, for example: Embed link to an embedded file).
Hiding an embedded file is also possible and fairly easy to do outside LaTeX (see, for example: https://blog.didierstevens.com/2009/07/01/embedding-and-hiding-files-in-pdf-documents/)
But I'm almost certain that it is possible to do the same (i.e., embed a file AND hide it from the attachment list) using only Latex…
Motivation: to be able to include the tex source code as an attachment that is hidden from the attachment list.
Any grey beard out there knowing the answer to this one?
Best Answer
The "hidden" embedded file in the blog post is not an embedded file in the sense of the PDF standard, so the question is what you really want:
If you only want to include the content from the file in the generated PDF, you can add a PDF stream: If you write
\immediate\pdfobj file{some-filename.tex}
, the filesome-filename.tex
is copied into the PDF as a stream. If you want to see this without writing a PDF parser, you can useIf you open the resulting PDF file in an editor, somewhere you will something like: (The first number may vary)
This object will not be visible in any PDF viewer.
Of course, this isn't really embedded. A second attempt: Embed the file, but do not list it in
/EmbeddedFiles
. You can useI partially disabled compression again so that you can find the file in the resulting PDF. The
\global\let\EmFi@list\empty
makes theembedfile
package forget about all the files up to this point, so they will never be written into the list of embedded files, but the/EmbeddedFile
PDF object with the file content and some metadata is still written. You can't easily make this visible, because the catalog entries are missing.If you try to reproduce the blog post you referenced and change the case of
/EmbeddedFiles
, you have to replace the output routine of embedfile: