Skip to content

Commit 5da2dae

Browse files
lfavoleLucas-C
andauthored
Fix #865 - PDF metadata not encrypted (#867)
Co-authored-by: Lucas Cimon <925560+Lucas-C@users.noreply.github.com>
1 parent 892d58a commit 5da2dae

6 files changed

+7
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
2929
- [`FPDF.image()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.image): allowing images path starting with `data` to be passed as input
3030
- text overflow is better handled by `FPDF.write()` & `FPDF.write_html()` - _cf._ [issue #847](https://github.com/PyFPDF/fpdf2/issues/847)
3131
- the initial text color is preserved when using `FPDF.write_html()` - _cf._ [issue #846](https://github.com/PyFPDF/fpdf2/issues/846)
32+
- PDF metadata not encrypted - _cf._ [issue #865](https://github.com/PyFPDF/fpdf2/issues/865)
3233
- handle superscript and subscript correctly when rendering `TextLine`- thanks to @Tolker-KU - _cf._ [Pull Request #862](https://github.com/PyFPDF/fpdf2/pull/862)
3334
### Deprecated
3435
- the `center` optional parameter of [`FPDF.cell()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.cell) is **no more** deprecated, as it allows for horizontal positioning, which is different from text alignment control with `align="C"`

fpdf/output.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ def __init__(
9090
creation_date: PDFDate,
9191
):
9292
super().__init__()
93-
self.title = PDFString(title) if title else None
94-
self.subject = PDFString(subject) if subject else None
95-
self.author = PDFString(author) if author else None
96-
self.keywords = PDFString(keywords) if keywords else None
97-
self.creator = PDFString(creator) if creator else None
98-
self.producer = PDFString(producer) if producer else None
93+
self.title = PDFString(title, encrypt=True) if title else None
94+
self.subject = PDFString(subject, encrypt=True) if subject else None
95+
self.author = PDFString(author, encrypt=True) if author else None
96+
self.keywords = PDFString(keywords, encrypt=True) if keywords else None
97+
self.creator = PDFString(creator, encrypt=True) if creator else None
98+
self.producer = PDFString(producer, encrypt=True) if producer else None
9999
self.creation_date = creation_date
100100

101101

test/encryption/encryption_aes128.pdf

132 Bytes
Binary file not shown.

test/encryption/encryption_rc4.pdf

28 Bytes
Binary file not shown.
28 Bytes
Binary file not shown.
28 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)