Skip to content

Commit 88d2223

Browse files
authored
Merge branch 'main' into ENH-py-pdf#2613-integration-of-images-inside-patterns
2 parents e5585d7 + 582557e commit 88d2223

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1756
-785
lines changed

.github/workflows/github-ci.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
runs-on: ubuntu-20.04
5858
strategy:
5959
matrix:
60-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
60+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
6161
use-crypto-lib: ["cryptography"]
6262
include:
6363
- python-version: "3.7"
@@ -90,7 +90,7 @@ jobs:
9090
cache-dependency-path: '**/requirements/ci.txt'
9191
- name: Setup Python (3.11+)
9292
uses: actions/setup-python@v5
93-
if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
93+
if: matrix.python-version == '3.11' || matrix.python-version == '3.12' || matrix.python-version == '3.13-dev'
9494
with:
9595
python-version: ${{ matrix.python-version }}
9696
allow-prereleases: true
@@ -106,7 +106,7 @@ jobs:
106106
- name: Install requirements (Python 3.11+)
107107
run: |
108108
pip install -r requirements/ci-3.11.txt
109-
if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
109+
if: matrix.python-version == '3.11' || matrix.python-version == '3.12' || matrix.python-version == '3.13-dev'
110110
- name: Remove pycryptodome and cryptography
111111
run: |
112112
pip uninstall pycryptodome cryptography -y
@@ -215,8 +215,8 @@ jobs:
215215
- name: Check Number of Downloaded Files
216216
run: |
217217
downloaded_files_count=$(find \.coverage* -type f | wc -l)
218-
if [ $downloaded_files_count -eq 8 ]; then
219-
echo "The expected number of files (8) were downloaded."
218+
if [ $downloaded_files_count -eq 9 ]; then
219+
echo "The expected number of files (9) were downloaded."
220220
else
221221
echo "ERROR: Expected 8 files, but found $downloaded_files_count files."
222222
exit 1

.github/workflows/release.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
permissions:
1313
contents: write
1414

15+
env:
16+
HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
17+
1518
jobs:
1619
build_and_publish:
1720
name: Publish a new version
@@ -24,15 +27,15 @@ jobs:
2427
- name: Extract version from commit message
2528
id: extract_version
2629
run: |
27-
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=REL: )\d+\.\d+\.\d+')
30+
VERSION=$(echo "$HEAD_COMMIT_MESSAGE" | grep -oP '(?<=REL: )\d+\.\d+\.\d+')
2831
echo "version=$VERSION" >> $GITHUB_OUTPUT
2932
3033
- name: Extract tag message from commit message
3134
id: extract_message
3235
run: |
3336
VERSION="${{ steps.extract_version.outputs.version }}"
3437
delimiter="$(openssl rand -hex 8)"
35-
MESSAGE=$(echo "${{ github.event.head_commit.message }}" | sed "0,/REL: $VERSION/s///" )
38+
MESSAGE=$(echo "$HEAD_COMMIT_MESSAGE" | sed "0,/REL: $VERSION/s///" )
3639
echo "message<<${delimiter}" >> $GITHUB_OUTPUT
3740
echo "$MESSAGE" >> $GITHUB_OUTPUT
3841
echo "${delimiter}" >> $GITHUB_OUTPUT

CHANGELOG.md

+50
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# CHANGELOG
22

3+
## Version 4.3.1, 2024-07-21
4+
5+
### Bug Fixes (BUG)
6+
- Cope with Matrix entry in field annotations (#2736)
7+
8+
### Robustness (ROB)
9+
- Cope with fields with upside down box/rectangle (#2729)
10+
11+
### Maintenance (MAINT)
12+
- Add deprecate_with_replacement to StreamObject.initializeFromD… (#2728)
13+
- Deal with cryptography>=43 moving ARC4 (#2765)
14+
15+
[Full Changelog](https://github.com/py-pdf/pypdf/compare/4.3.0...4.3.1)
16+
17+
## Version 4.3.0, 2024-06-23
18+
19+
### New Features (ENH)
20+
- Accept ETen-B5 and UniCNS-UTF16 encodings (#2721)
21+
- Add decode_as_image() to ContentStreams (#2615)
22+
- context manager for PdfReader (#2666)
23+
- Add capability to set font and size in fields (#2636)
24+
- Allow to pass input file without named argument (#2576)
25+
26+
### Bug Fixes (BUG)
27+
- Fix deprecation for Ressources when using old constants (#2705)
28+
- Fix images issue 4 bits encoding and LUT starting with UTF16_BOM (#2675)
29+
- Reading large compressed images takes huge time to process (#2644)
30+
- Highlighted Text Cannot Be Printed (#2604)
31+
- Fix UnboundLocalError on malformed pdf (#2619)
32+
33+
### Robustness (ROB)
34+
- Cope with missing Standard 14 fonts in fields (#2677)
35+
- Improve inline image extraction (#2622)
36+
- Cope with loops in Fields tree (#2656)
37+
- Discard /I in choice fields for compatibility with Acrobat (#2614)
38+
- Cope with some issues in pillow (#2595)
39+
- Cope with some image extraction issues (#2591)
40+
41+
### Documentation (DOC)
42+
- Various improvements on docstrings and examples
43+
44+
### Maintenance (MAINT)
45+
- Deprecate interiour_color with replacement interior_color (#2706)
46+
- Add deprecate_with_replacement to PdfWriter.find_bookmark (#2674)
47+
48+
### Code Style (STY)
49+
- Change Link to be a non-markup annotation (#2714)
50+
51+
[Full Changelog](https://github.com/py-pdf/pypdf/compare/4.2.0...4.3.0)
52+
353
## Version 4.2.0, 2024-04-07
454

555
### New Features (ENH)

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Please use the templates provided.
1515
We appreciate if people make PRs, but please be aware that pypdf is used by many
1616
people. That means:
1717

18-
* We rarely make breaking changes and have a [deprecation process](https://pypdf.readthedocs.io/en/latest/dev/deprecations.html)
18+
* We rarely make breaking changes and have a [deprecation process](https://pypdf.readthedocs.io/en/latest/dev/deprecations.html).
1919
* New features, especially adding to the public interface, typically need to be
2020
discussed first.
2121

22-
Before you make bigger changes, rather open an issue to make the suggestion.
22+
Before you make bigger changes, open an issue to make the suggestion.
2323
Note which interface changes you want to make.

CONTRIBUTORS.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Contributors
22

3-
pypdf had a lot of contributors since it started with pyPdf in 2005. We are
3+
pypdf had a lot of contributors since it started as pyPdf in 2005. We are
44
a free software project without any company affiliation. We cannot pay
55
contributors, but we do value their contributions. A lot of time, effort, and
6-
expertise went into this project. With this list, we recognize those awesome
6+
expertise went into this project. With this list, we recognize these awesome
77
people 🤗
88

99
The list is definitely not complete. You can find more contributors via the git
10-
history and [GitHubs 'Contributors' feature](https://github.com/py-pdf/pypdf/graphs/contributors).
10+
history and [GitHub's 'Contributors' feature](https://github.com/py-pdf/pypdf/graphs/contributors).
1111

1212
## Contributors to the pypdf (formerly pyPdf / PyPDF2) project
1313

@@ -19,6 +19,7 @@ history and [GitHubs 'Contributors' feature](https://github.com/py-pdf/pypdf/gra
1919
* [ediamondscience](https://github.com/ediamondscience)
2020
* [Ermeson, Felipe](https://github.com/FelipeErmeson)
2121
* [Freitag, François](https://github.com/francoisfreitag)
22+
* [Gagnon, William G.](https://github.com/williamgagnon)
2223
* [Górny, Michał](https://github.com/mgorny)
2324
* [Grillo, Miguel](https://github.com/Ineffable22)
2425
* [Gutteridge, David H.](https://github.com/dhgutteridge)

docs/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# If extensions (or modules to document with autodoc) are in another directory,
1111
# add these directories to sys.path here. If the directory is relative to the
1212
# documentation root, use os.path.abspath to make it absolute, like shown here.
13+
import datetime
1314
import os
1415
import shutil
1516
import sys
@@ -25,7 +26,7 @@
2526
# -- Project information -----------------------------------------------------
2627

2728
project = py_pkg.__name__
28-
copyright = "2006 - 2023, Mathieu Fenniak and pypdf contributors"
29+
copyright = f"2006 - {datetime.datetime.now(tz=datetime.timezone.utc).year}, Mathieu Fenniak and pypdf contributors"
2930
author = "Mathieu Fenniak"
3031

3132
# The version info for the project you're documenting, acts as replacement for
@@ -93,13 +94,13 @@
9394

9495
# -- Options for HTML output -------------------------------------------------
9596

96-
# The theme to use for HTML and HTML Help pages. See the documentation for
97+
# The theme to use for HTML and HTML Help pages. See the documentation for
9798
# a list of builtin themes.
9899
#
99100
html_theme = "sphinx_rtd_theme"
100101

101102
# Theme options are theme-specific and customize the look and feel of a theme
102-
# further. For a list of options available for each theme, see the
103+
# further. For a list of options available for each theme, see the
103104
# documentation.
104105
html_theme_options = {
105106
"canonical_url": "",

docs/dev/cmaps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ It defines a starting point:
4040
That means that `1B` (Hex for 27) maps to the unicode character [`FB00`](https://unicode-table.com/en/FB00/) - the ligature ff (two lowercase f's).
4141

4242
The two numbers in `begincodespacerange` mean that it starts with an offset of
43-
0 (hence from `1B ➜ FB00`) upt to an offset of FF (dec: 255), hence 1B+FF = 282
43+
0 (hence from `1B ➜ FB00`) up to an offset of FF (dec: 255), hence 1B+FF = 282
4444
[FBFF](https://www.compart.com/de/unicode/U+FBFF).
4545

4646
Within the text stream, there is

docs/dev/testing.md

-20
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@ You can even disable all of them: `pytest -m "not enable_socket" -m "not samples
1919

2020
Please note that this reduces test coverage. The CI will always test all files.
2121

22-
## Creating a Coverage Report
23-
24-
If you want to get a coverage report that considers the Python version specific
25-
code, you can run [`tox`](https://tox.wiki/en/latest/).
26-
27-
As a prerequisite, we recommend using [`pyenv`](https://github.com/pyenv/pyenv)
28-
so that you can install the different Python versions:
29-
30-
```
31-
pyenv install pypy3.8-7.3.7
32-
pyenv install 3.7.15
33-
pyenv install 3.8.12
34-
pyenv install 3.9.10
35-
pyenv install 3.10.2
36-
```
37-
38-
Then you can execute `tox` which will create a coverage report in HTML form
39-
in the end. The execution takes about 30 minutes.
40-
41-
4222
## Docstrings in Unit tests
4323

4424
The first line of a docstring in a unit test should be written in a way that

docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ You can contribute to `pypdf on GitHub <https://github.com/py-pdf/pypdf>`_.
3232
user/encryption-decryption
3333
user/merging-pdfs
3434
user/cropping-and-transforming
35-
user/add-watermark
3635
user/reading-pdf-annotations
3736
user/adding-pdf-annotations
37+
user/add-watermark
38+
user/add-javascript
3839
user/viewer-preferences
3940
user/forms
4041
user/streaming-data

docs/meta/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Frequently-Asked Questions
1+
# Frequently Asked Questions
22

33
## How is pypdf related to PyPDF2?
44

docs/modules/constants.rst

+6
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ Constants
2020
:members:
2121
:undoc-members:
2222
:show-inheritance:
23+
24+
.. autoclass:: pypdf.constants.FieldDictionaryAttributes
25+
:members:
26+
:undoc-members:
27+
:exclude-members: FT, Parent, Kids, T, TU, TM, V, DV, AA, Opt, attributes, attributes_dict
28+
:show-inheritance:

docs/user/add-javascript.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Adding JavaScript to a PDF
2+
3+
PDF readers vary in the extent they support JavaScript, with some not supporting it at all.
4+
5+
Adobe has documentation on its support here:
6+
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html
7+
8+
## Launch print window on opening
9+
10+
```python
11+
from pypdf import PdfWriter
12+
13+
writer = PdfWriter(clone_from="example.pdf")
14+
15+
# Add JavaScript to launch the print window on opening this PDF.
16+
writer.add_js("this.print({bUI:true,bSilent:false,bShrinkToFit:true});")
17+
18+
# Write to pypdf-output.pdf.
19+
with open("pypdf-output.pdf", "wb") as fp:
20+
writer.write(fp)
21+
```

docs/user/add-watermark.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The process of stamping and watermarking is the same, you just need to set `over
1111
You can use `merge_page()` if you don't need to transform the stamp:
1212

1313
```python
14-
from pypdf import PdfWriter, PdfReader
14+
from pypdf import PdfReader, PdfWriter
1515

1616
stamp = PdfReader("bg.pdf").pages[0]
1717
writer = PdfWriter(clone_from="source.pdf")

docs/user/adding-pdf-annotations.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,12 @@ with open("annotated-pdf.pdf", "wb") as fp:
215215

216216
## Popup
217217

218-
Manage the Popup windows for markups. looks like this:
218+
Manage the Popup windows for markups, looks like this:
219219

220220
![](annotation-popup.png)
221221

222222
you can use the {py:class}`Popup <pypdf.annotations.Popup>`:
223223

224-
you have to use the returned result from add_annotation() to fill-up the
225-
226224
```python
227225
from pypdf.annotations import Popup, Text
228226

@@ -249,6 +247,9 @@ popup_annotation = Popup(
249247
writer.write("annotated-pdf-popup.pdf")
250248
```
251249

250+
You have to use the returned result from add_annotation() as it is
251+
the parent annotation with which this popup annotation shall be associated.
252+
252253
## Link
253254

254255
If you want to add a link, you can use
@@ -264,7 +265,7 @@ page = reader.pages[0]
264265
writer = PdfWriter()
265266
writer.add_page(page)
266267

267-
# Add the line
268+
# Add the link
268269
annotation = Link(
269270
rect=(50, 550, 200, 650),
270271
url="https://martin-thoma.com/",
@@ -281,16 +282,19 @@ You can also add internal links:
281282
```python
282283
from pypdf import PdfReader, PdfWriter
283284
from pypdf.annotations import Link
285+
from pypdf.generic import Fit
284286

285287
pdf_path = os.path.join(RESOURCE_ROOT, "crazyones.pdf")
286288
reader = PdfReader(pdf_path)
287289
page = reader.pages[0]
288290
writer = PdfWriter()
289291
writer.add_page(page)
290292

291-
# Add the line
293+
# Add the link
292294
annotation = Link(
293-
rect=(50, 550, 200, 650), target_page_index=3, fit="/FitH", fit_args=(123,)
295+
rect=(50, 550, 200, 650),
296+
target_page_index=3,
297+
fit=Fit(fit_type="/FitH", fit_args=(123,)),
294298
)
295299
writer.add_annotation(page_number=0, annotation=annotation)
296300

@@ -303,7 +307,7 @@ with open("annotated-pdf.pdf", "wb") as fp:
303307

304308
Text markup annotations refer to a specific piece of text within the document.
305309

306-
Those are a bit more complicated as you need to know exactly where the text
310+
These are a bit more complicated as you need to know exactly where the text
307311
is, the so-called "Quad points".
308312

309313
### Highlighting

0 commit comments

Comments
 (0)