Skip to content

Commit ce70b1c

Browse files
authored
Merge branch 'main' into missing-bookmark
2 parents cc09600 + 7d820f0 commit ce70b1c

8 files changed

Lines changed: 29 additions & 6 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ testtype:
2525
mutation-test:
2626
mutmut run
2727

28-
mutmut-results:
28+
mutation-results:
2929
mutmut junitxml --suspicious-policy=ignore --untested-policy=ignore > mutmut-results.xml
3030
junit2html mutmut-results.xml mutmut-results.html
3131

PyPDF2/_writer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ def add_uri(
13391339
) -> None:
13401340
"""
13411341
Add an URI from a rectangular area to the specified page.
1342-
This uses the basic structure of AddLink
1342+
This uses the basic structure of :meth:`add_link`
13431343
13441344
:param int pagenum: index of the page on which to place the URI action.
13451345
:param int uri: string -- uri of resource to link to.
@@ -1349,9 +1349,6 @@ def add_uri(
13491349
:param border: if provided, an array describing border-drawing
13501350
properties. See the PDF spec for details. No border will be
13511351
drawn if this argument is omitted.
1352-
1353-
REMOVED FIT/ZOOM ARG
1354-
-John Mulligan
13551352
"""
13561353

13571354
page_link = self.get_object(self._pages)[PA.KIDS][pagenum] # type: ignore

PyPDF2/generic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,11 @@ def write_to_stream(
565565
stream.write(b"(")
566566
for c in bytearr:
567567
if not chr(c).isalnum() and c != b" ":
568-
stream.write(b_(rf"\{c:0>3o}"))
568+
# This:
569+
# stream.write(b_(rf"\{c:0>3o}"))
570+
# gives
571+
# https://github.com/davidhalter/parso/issues/207
572+
stream.write(b_("\\%03o" % c))
569573
else:
570574
stream.write(b_(chr(c)))
571575
stream.write(b")")

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ You can install PyPDF2 via pip:
2727
pip install PyPDF2
2828
```
2929

30+
If you plan to use PyPDF2 for encrypting or decrypting PDFs that use AES, you
31+
will need to install some extra dependencies. Encryption using RC4 is supported
32+
using the regular installation.
33+
34+
```
35+
pip install PyPDF2[crypto]
36+
```
37+
3038
## Usage
3139

3240
```python

docs/user/encryption-decryption.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Encryption and Decryption of PDFs
22

3+
Please see the note in the
4+
[Installation doc](https://pypdf2.readthedocs.io/en/latest/user/installation.html)
5+
for installing the extra dependencies if interacting with PDFs that use AES.
6+
37
## Encrypt
48

59
Add a password to a PDF (encrypt it):

docs/user/installation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ install PyPDF2 for your current user:
2020
pip install --user PyPDF2
2121
```
2222

23+
If you plan to use PyPDF2 for encrypting or decrypting PDFs that use AES, you
24+
will need to install some extra dependencies. Encryption using RC4 is supported
25+
using the regular installation.
26+
27+
```
28+
pip install PyPDF2[crypto]
29+
```
30+
2331
## Anaconda
2432

2533
Anaconda users can [install PyPDF2 via conda-forge](https://anaconda.org/conda-forge/pypdf2).

mutmut-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/bash -e
22
pytest -x
3+
mypy PyPDF2 --show-error-codes --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports

tests/test_writer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def test_encrypt(use_128bit):
291291

292292
reader = PdfReader(tmp_filename, password="userpwd")
293293
new_text = reader.pages[0].extract_text()
294+
assert reader.metadata.get("/Producer") == "PyPDF2"
294295

295296
assert new_text == orig_text
296297

0 commit comments

Comments
 (0)