Skip to content

Commit

Permalink
Merge branch 'main' into ENH-py-pdf#2613-integration-of-images-inside…
Browse files Browse the repository at this point in the history
…-patterns
  • Loading branch information
0xNath authored Aug 3, 2024
2 parents e5585d7 + 582557e commit 88d2223
Show file tree
Hide file tree
Showing 66 changed files with 1,756 additions and 785 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
use-crypto-lib: ["cryptography"]
include:
- python-version: "3.7"
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
cache-dependency-path: '**/requirements/ci.txt'
- name: Setup Python (3.11+)
uses: actions/setup-python@v5
if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
if: matrix.python-version == '3.11' || matrix.python-version == '3.12' || matrix.python-version == '3.13-dev'
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
Expand All @@ -106,7 +106,7 @@ jobs:
- name: Install requirements (Python 3.11+)
run: |
pip install -r requirements/ci-3.11.txt
if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
if: matrix.python-version == '3.11' || matrix.python-version == '3.12' || matrix.python-version == '3.13-dev'
- name: Remove pycryptodome and cryptography
run: |
pip uninstall pycryptodome cryptography -y
Expand Down Expand Up @@ -215,8 +215,8 @@ jobs:
- name: Check Number of Downloaded Files
run: |
downloaded_files_count=$(find \.coverage* -type f | wc -l)
if [ $downloaded_files_count -eq 8 ]; then
echo "The expected number of files (8) were downloaded."
if [ $downloaded_files_count -eq 9 ]; then
echo "The expected number of files (9) were downloaded."
else
echo "ERROR: Expected 8 files, but found $downloaded_files_count files."
exit 1
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
permissions:
contents: write

env:
HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}

jobs:
build_and_publish:
name: Publish a new version
Expand All @@ -24,15 +27,15 @@ jobs:
- name: Extract version from commit message
id: extract_version
run: |
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=REL: )\d+\.\d+\.\d+')
VERSION=$(echo "$HEAD_COMMIT_MESSAGE" | grep -oP '(?<=REL: )\d+\.\d+\.\d+')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract tag message from commit message
id: extract_message
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
delimiter="$(openssl rand -hex 8)"
MESSAGE=$(echo "${{ github.event.head_commit.message }}" | sed "0,/REL: $VERSION/s///" )
MESSAGE=$(echo "$HEAD_COMMIT_MESSAGE" | sed "0,/REL: $VERSION/s///" )
echo "message<<${delimiter}" >> $GITHUB_OUTPUT
echo "$MESSAGE" >> $GITHUB_OUTPUT
echo "${delimiter}" >> $GITHUB_OUTPUT
Expand Down
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# CHANGELOG

## Version 4.3.1, 2024-07-21

### Bug Fixes (BUG)
- Cope with Matrix entry in field annotations (#2736)

### Robustness (ROB)
- Cope with fields with upside down box/rectangle (#2729)

### Maintenance (MAINT)
- Add deprecate_with_replacement to StreamObject.initializeFromD… (#2728)
- Deal with cryptography>=43 moving ARC4 (#2765)

[Full Changelog](https://github.com/py-pdf/pypdf/compare/4.3.0...4.3.1)

## Version 4.3.0, 2024-06-23

### New Features (ENH)
- Accept ETen-B5 and UniCNS-UTF16 encodings (#2721)
- Add decode_as_image() to ContentStreams (#2615)
- context manager for PdfReader (#2666)
- Add capability to set font and size in fields (#2636)
- Allow to pass input file without named argument (#2576)

### Bug Fixes (BUG)
- Fix deprecation for Ressources when using old constants (#2705)
- Fix images issue 4 bits encoding and LUT starting with UTF16_BOM (#2675)
- Reading large compressed images takes huge time to process (#2644)
- Highlighted Text Cannot Be Printed (#2604)
- Fix UnboundLocalError on malformed pdf (#2619)

### Robustness (ROB)
- Cope with missing Standard 14 fonts in fields (#2677)
- Improve inline image extraction (#2622)
- Cope with loops in Fields tree (#2656)
- Discard /I in choice fields for compatibility with Acrobat (#2614)
- Cope with some issues in pillow (#2595)
- Cope with some image extraction issues (#2591)

### Documentation (DOC)
- Various improvements on docstrings and examples

### Maintenance (MAINT)
- Deprecate interiour_color with replacement interior_color (#2706)
- Add deprecate_with_replacement to PdfWriter.find_bookmark (#2674)

### Code Style (STY)
- Change Link to be a non-markup annotation (#2714)

[Full Changelog](https://github.com/py-pdf/pypdf/compare/4.2.0...4.3.0)

## Version 4.2.0, 2024-04-07

### New Features (ENH)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Please use the templates provided.
We appreciate if people make PRs, but please be aware that pypdf is used by many
people. That means:

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

Before you make bigger changes, rather open an issue to make the suggestion.
Before you make bigger changes, open an issue to make the suggestion.
Note which interface changes you want to make.
7 changes: 4 additions & 3 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Contributors

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

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

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

Expand All @@ -19,6 +19,7 @@ history and [GitHubs 'Contributors' feature](https://github.com/py-pdf/pypdf/gra
* [ediamondscience](https://github.com/ediamondscience)
* [Ermeson, Felipe](https://github.com/FelipeErmeson)
* [Freitag, François](https://github.com/francoisfreitag)
* [Gagnon, William G.](https://github.com/williamgagnon)
* [Górny, Michał](https://github.com/mgorny)
* [Grillo, Miguel](https://github.com/Ineffable22)
* [Gutteridge, David H.](https://github.com/dhgutteridge)
Expand Down
7 changes: 4 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import datetime
import os
import shutil
import sys
Expand All @@ -25,7 +26,7 @@
# -- Project information -----------------------------------------------------

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

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

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"canonical_url": "",
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/cmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ It defines a starting point:
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).

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

Within the text stream, there is
Expand Down
20 changes: 0 additions & 20 deletions docs/dev/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@ You can even disable all of them: `pytest -m "not enable_socket" -m "not samples

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

## Creating a Coverage Report

If you want to get a coverage report that considers the Python version specific
code, you can run [`tox`](https://tox.wiki/en/latest/).

As a prerequisite, we recommend using [`pyenv`](https://github.com/pyenv/pyenv)
so that you can install the different Python versions:

```
pyenv install pypy3.8-7.3.7
pyenv install 3.7.15
pyenv install 3.8.12
pyenv install 3.9.10
pyenv install 3.10.2
```

Then you can execute `tox` which will create a coverage report in HTML form
in the end. The execution takes about 30 minutes.


## Docstrings in Unit tests

The first line of a docstring in a unit test should be written in a way that
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ You can contribute to `pypdf on GitHub <https://github.com/py-pdf/pypdf>`_.
user/encryption-decryption
user/merging-pdfs
user/cropping-and-transforming
user/add-watermark
user/reading-pdf-annotations
user/adding-pdf-annotations
user/add-watermark
user/add-javascript
user/viewer-preferences
user/forms
user/streaming-data
Expand Down
2 changes: 1 addition & 1 deletion docs/meta/faq.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Frequently-Asked Questions
# Frequently Asked Questions

## How is pypdf related to PyPDF2?

Expand Down
6 changes: 6 additions & 0 deletions docs/modules/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ Constants
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pypdf.constants.FieldDictionaryAttributes
:members:
:undoc-members:
:exclude-members: FT, Parent, Kids, T, TU, TM, V, DV, AA, Opt, attributes, attributes_dict
:show-inheritance:
21 changes: 21 additions & 0 deletions docs/user/add-javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Adding JavaScript to a PDF

PDF readers vary in the extent they support JavaScript, with some not supporting it at all.

Adobe has documentation on its support here:
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html

## Launch print window on opening

```python
from pypdf import PdfWriter

writer = PdfWriter(clone_from="example.pdf")

# Add JavaScript to launch the print window on opening this PDF.
writer.add_js("this.print({bUI:true,bSilent:false,bShrinkToFit:true});")

# Write to pypdf-output.pdf.
with open("pypdf-output.pdf", "wb") as fp:
writer.write(fp)
```
2 changes: 1 addition & 1 deletion docs/user/add-watermark.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The process of stamping and watermarking is the same, you just need to set `over
You can use `merge_page()` if you don't need to transform the stamp:

```python
from pypdf import PdfWriter, PdfReader
from pypdf import PdfReader, PdfWriter

stamp = PdfReader("bg.pdf").pages[0]
writer = PdfWriter(clone_from="source.pdf")
Expand Down
18 changes: 11 additions & 7 deletions docs/user/adding-pdf-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,12 @@ with open("annotated-pdf.pdf", "wb") as fp:

## Popup

Manage the Popup windows for markups. looks like this:
Manage the Popup windows for markups, looks like this:

![](annotation-popup.png)

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

you have to use the returned result from add_annotation() to fill-up the

```python
from pypdf.annotations import Popup, Text

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

You have to use the returned result from add_annotation() as it is
the parent annotation with which this popup annotation shall be associated.

## Link

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

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

pdf_path = os.path.join(RESOURCE_ROOT, "crazyones.pdf")
reader = PdfReader(pdf_path)
page = reader.pages[0]
writer = PdfWriter()
writer.add_page(page)

# Add the line
# Add the link
annotation = Link(
rect=(50, 550, 200, 650), target_page_index=3, fit="/FitH", fit_args=(123,)
rect=(50, 550, 200, 650),
target_page_index=3,
fit=Fit(fit_type="/FitH", fit_args=(123,)),
)
writer.add_annotation(page_number=0, annotation=annotation)

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

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

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

### Highlighting
Expand Down
Loading

0 comments on commit 88d2223

Please sign in to comment.