[luatex] setting metadata for pdf

Reinhard Kotucha reinhard.kotucha at web.de
Mon Apr 14 20:50:52 CEST 2014


On 2014-04-10 at 22:46:39 +0200, andrea del monaco wrote:

 > Hi everyone!
 > I'm writing about the metadata of pdf.
 > The point is that I would like to set them for the file generated by
 > lualatex.
 > So, the question: how to do this?
 > 
 > I know that it can be done via \pdfinfo from pdftex, but I would like
 > to know if it is possible to achieve the same result via lua(la)tex.
 > I am aware of the existence of the library pdf, but I didn't really
 > get how to use it.

pdf.info="/Title (Some Document) /Author (Ben Lee User)"

 > Moreover, I would like to know if it is even possible to set other
 > fields, for instance those ones that the combo hyperxmp+hyperref
 > lets you set.

If you intend to create PDF/A or PDF/X then you could join the mailing
list

  http://lists.river-valley.com/cgi-bin/mailman/listinfo/tex

There is very low traffic.
  
 
You can try the following example as a starting point.
 
testXMP.lua:
------------------------------------------------------------------
xmpobj = pdf.obj{
  type='stream',
       immediate=true,
       attr='/Type/Metadata/Subtype/XML',
       compresslevel=0,
       string='*** XMP matadata supposed to be inserted here ***'
  }
pdf.refobj(xmpobj)
meta=string.format('/Metadata %d 0 R', xmpobj)
pdf.catalog=meta
------------------------------------------------------------------

testXMP.tex:
------------------------------------------------------------------
\pdfminorversion=4
\pdfobjcompresslevel=0
\pdfcompresslevel=0

\documentclass{article}
\nofiles\pagestyle{empty}

\directlua{dofile("testXMP.lua")}

\begin{document}
\leavevmode
\end{document}
------------------------------------------------------------------

 > Finally: does there exist a way to set a password to protect the
 > pdf using luatex?

No, password protection requires encryption.  Adding encryption to
pdfTeX or LuaTeX is nearly impossible.  An attempt was made several
years ago with pdfTeX but it turned out that it makes the code
unmaintainable.  You can use a post-processor like pdftk or qpdf.

qpdf supports AES encryption.  I don't know which algorithms are
supported by pdftk.  Keep in mind that MD5 is utterly insecure.

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------



More information about the luatex mailing list