Changes

Jump to navigation Jump to search
808 bytes added ,  18:55, 11 September 2021
import PDF metadata fields from other document
</texcode>}}
 
== Import PDF metadata fields from other PDF documents==
 
Inspired by a [https://mailman.ntg.nl/pipermail/ntg-context/2021/103556.html reply from Hans], here is a minimal sample:
 
<texcode>
\starttext
\startluacode
function document.transfer_metadata(name)
local main_doc = lpdf.epdf.load(name)
lpdf.addtocatalog("Lang", lpdf.string(main_doc.Catalog.Lang))
lpdf.addtoinfo("Title", lpdf.unicode(main_doc.Info.Title))
lpdf.addtoinfo("Subject", lpdf.unicode(main_doc.Info.Subject))
lpdf.addtoinfo("Author", lpdf.unicode(main_doc.Info.Author))
lpdf.epdf.unload(name)
end
\stopluacode
\unexpanded\def\TransferMetadata#1%
{\ctxlua{document.transfer_metadata("#1")}}
\null
\TransferMetadata{name.pdf}
\stoptext
</texcode>
 
It also imports language to the PDF document (not to the document language).
= Further reading =
86

edits

Navigation menu