Skip to content

Commit

Permalink
Merge branch 'main' into missing-bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Jun 23, 2022
2 parents cc09600 + 7d820f0 commit ce70b1c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ testtype:
mutation-test:
mutmut run

mutmut-results:
mutation-results:
mutmut junitxml --suspicious-policy=ignore --untested-policy=ignore > mutmut-results.xml
junit2html mutmut-results.xml mutmut-results.html

Expand Down
5 changes: 1 addition & 4 deletions PyPDF2/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ def add_uri(
) -> None:
"""
Add an URI from a rectangular area to the specified page.
This uses the basic structure of AddLink
This uses the basic structure of :meth:`add_link`
:param int pagenum: index of the page on which to place the URI action.
:param int uri: string -- uri of resource to link to.
Expand All @@ -1349,9 +1349,6 @@ def add_uri(
:param border: if provided, an array describing border-drawing
properties. See the PDF spec for details. No border will be
drawn if this argument is omitted.
REMOVED FIT/ZOOM ARG
-John Mulligan
"""

page_link = self.get_object(self._pages)[PA.KIDS][pagenum] # type: ignore
Expand Down
6 changes: 5 additions & 1 deletion PyPDF2/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,11 @@ def write_to_stream(
stream.write(b"(")
for c in bytearr:
if not chr(c).isalnum() and c != b" ":
stream.write(b_(rf"\{c:0>3o}"))
# This:
# stream.write(b_(rf"\{c:0>3o}"))
# gives
# https://github.com/davidhalter/parso/issues/207
stream.write(b_("\\%03o" % c))
else:
stream.write(b_(chr(c)))
stream.write(b")")
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ You can install PyPDF2 via pip:
pip install PyPDF2
```

If you plan to use PyPDF2 for encrypting or decrypting PDFs that use AES, you
will need to install some extra dependencies. Encryption using RC4 is supported
using the regular installation.

```
pip install PyPDF2[crypto]
```

## Usage

```python
Expand Down
4 changes: 4 additions & 0 deletions docs/user/encryption-decryption.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Encryption and Decryption of PDFs

Please see the note in the
[Installation doc](https://pypdf2.readthedocs.io/en/latest/user/installation.html)
for installing the extra dependencies if interacting with PDFs that use AES.

## Encrypt

Add a password to a PDF (encrypt it):
Expand Down
8 changes: 8 additions & 0 deletions docs/user/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ install PyPDF2 for your current user:
pip install --user PyPDF2
```

If you plan to use PyPDF2 for encrypting or decrypting PDFs that use AES, you
will need to install some extra dependencies. Encryption using RC4 is supported
using the regular installation.

```
pip install PyPDF2[crypto]
```

## Anaconda

Anaconda users can [install PyPDF2 via conda-forge](https://anaconda.org/conda-forge/pypdf2).
Expand Down
1 change: 1 addition & 0 deletions mutmut-test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash -e
pytest -x
mypy PyPDF2 --show-error-codes --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports
1 change: 1 addition & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def test_encrypt(use_128bit):

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

assert new_text == orig_text

Expand Down

0 comments on commit ce70b1c

Please sign in to comment.