# Embed a file with LuaTeX and hyperref and setting AFRelationship

I want to embed files in a pdf. I do need a /AFRelationship entry in the PDF because this is mandated by PDF/A. The minimal example below works for pdfTeX. It also works with LuaTeX when hyperref is disabled. However it does not work with hyperref and LuaTeX.

### MWE

\documentclass{article}
\usepackage{embedfile}
\usepackage{hyperref}
\embedfile[afrelationship={/Source}]{\jobname.tex}

\begin{document}
Text
\end{document}


### MWE output

produces

<</Type/Filespec/F(testbrief.tex)/AFRelationship\376\377\000/\000S\000o\000u\000r\000c\000e/EF<</F 1 0 R>>>>


This throws a validation error in Acrobat DC's Preflight for PDF/A3-b:
With hyperref disabled I get

<</Type/Filespec/F(testbrief.tex)/AFRelationship/Source/EF<</F 1 0 R>>>>



which passes validation.

### Question

Since I need luatex for font handling and hyperref for links and metadata this is a problem. How to get around this?

## Update

A corrected version of embedfile has been uploaded to ctan. The patch is no longer needed. The entry looks now, without the patch, like this

<</Type/Filespec/F(a.tex)/AFRelationship/Source/EF<</F 1 0 R>>>>


It is a bug. Embedfile shouldn't try to convert this value.

Try this patch

\documentclass{article}
\usepackage{l3pdf}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff
\usepackage{embedfile}
\usepackage{etoolbox}
\makeatletter
\patchcmd\EmFi@embedfile
{\EmFi@convert\EmFi@afrelationship\EmFi@@afrelationship}
{\let\EmFi@@afrelationship\EmFi@afrelationship}{}{\fail}
\makeatother

\usepackage{hyperref}

\embedfile[afrelationship={/Source}]{embedtest.tex}
\begin{document}
Text
\end{document}