Skip to content

Commit 8cacb0f

Browse files
DOC: Document easier way to update metadata (#2454)
1 parent 3fb63f7 commit 8cacb0f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/user/metadata.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,24 @@ writer.add_metadata(
5959
with open("meta-pdf.pdf", "wb") as f:
6060
writer.write(f)
6161
```
62+
63+
## Updating metadata
64+
65+
```python
66+
from pypdf import PdfReader, PdfWriter
67+
68+
writer = PdfWriter(clone_from="example.pdf")
69+
70+
# Change some values.
71+
writer.add_metadata(
72+
{
73+
"/Author": "Martin",
74+
"/Producer": "Libre Writer",
75+
"/Title": "Title",
76+
}
77+
)
78+
79+
# Save the new PDF to a file
80+
with open("meta-pdf.pdf", "wb") as f:
81+
writer.write(f)
82+
```

0 commit comments

Comments
 (0)