DocumentWriter.set_metadata #2696
Answered
by
JorjMcKie
vb64
asked this question in
Looking for help
-
I use DocumentWriter to convert html Story to pdf. How can I set the META properties for document (doc.set_metadata)? |
Beta Was this translation helpful? Give feedback.
Answered by
JorjMcKie
Sep 27, 2023
Replies: 2 comments 3 replies
-
Depeding on whether you are ok with PDF's standard metadata (no own, non-standard information keys), prepare a dictionary with the following keywords (or a subset of them): m = {'author': 'as desired',
'creationDate': "D:20161124064334-04'00'", # you can use fitz.get_pdf_now()
'creator': 'as desired',
'keywords': 'comma-separated',
'modDate': "D:20200301055940-04'00'",
'producer': 'as desired, usually the software',
'subject': 'as desired',
'title': 'as desired',
}
# then do:
doc.set_metadata(m) |
Beta Was this translation helpful? Give feedback.
1 reply
-
I use DocumentWriter, not Document. Haw I can access to metadata with writer object? Without writer.close() and then reopen by fitz.open(saved_file)? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, ok.
You can use DocumentWriter to write to a io.BytsIO(). Then open that memory piece again as a fitz.Document:
doc = fitz.open("pdf", fp.getvalue())
, wherefp = io.BytesIO()
and DocumentWriter has written to fp.