Search code examples
pythonreportlab

Add Name and Value in PDF Document Properties \ Custom with Reportlab


I am wondering if is possible to add new Names & Values (new attributes) to the PDF Document Properties \ Custom (AKA Metadata).

I've been looking to the documentation but it seems they don't speak about it. Only the metadata Author, Keywords, etc inside Document Properties \ Description.

Thanks in advance.


Solution

  • It seems that this is not possible, I checked the source code which actually specifies the reason why:

    PDF documents can have basic information embedded, viewable from File | Document Info in Acrobat Reader. If this is wrong, you get Postscript errors while printing, even though it does not print.

    Sourcecode

    As printing is one of the main goals of a PDF document (and not being able to print them sucks) it therefor makes sense to protect these properties.

    The only options that are available in the PDFDocument class are: setTitle, setAuthor, setSubject, setCreator, setKeywords, setDateFormatter. Most likely because these are the only one that are hard to get wrong.