I want to add custom metadata to pdf file. This can be achieved by pypdf2 or pdrw library. I have referred Change metadata of pdf file with pypdf2 solution works fine, when there is no space between the two words of attribute.
In my case my metadata is like
meta = {'Page description' : 'description',
'create time' : '123455' }
when I try to add above metadata as :
reader = PdfFileReader(filename)
writer = PdfFileWriter()
writer.appendPagesFromReader(reader)
writer.addMetadata(meta)
with open(filename, 'wb') as fout:
writer.write(fout)
when we try to see the custom properties in document property of pdf, nothing is displayed.
The above solution works fine if attributes are without spaces
I do not know about pypdfw, but for pdfrw, you should use PdfName('Page description') as your dictionary key. This will properly encode the space.
Disclaimer: I am the primary pdfrw author.