reportlab - Embedding documents in PDF files -


we want store application specific metadata (a json object) within pdf documents create.

we tried use canvas.setkeyword , pdffilereader.documentinfo["/keywords"]

this works 100 kb file, hangs 1 mb file (documentinfo return needs long time > 1min)

is there way embed file pdf document reportlab? there way read pypdf2?

(this may or may not enough answer, don't yet have reputation able comment...)

one possible reason long delay might encoding process string. if don't mind reading pdf in, adding data , writing out, might try pdfrw. (disclaimer: pdfrw author.) code like:

     pdfrw import pdfreader, pdfwriter     trailer = pdfreader('source.pdf')     trailer.info.keywords = my_json_string     pdfwriter().write('dest.pdf', trailer) 

if isn't fast enough because of string encoding, store data in stream somewhere else in file (and compress it, if desired).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -