Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pillow. Drop Python 3.8 support. (#78) #79

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
# - "3.8"
# - "3.7"
steps:
- name: Install wkhtmltopdf
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.17.13
-------
2024-10-30

- Upgrade `Pillow` related code to work with `Pillow`>=9.1.0 (tested with
10.x and 11.x).
- Drop EOL Python 3.8 support.

0.17.12
-------
2024-09-10
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -254,7 +254,7 @@ webencodings==0.5.1
# tinycss2
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
yarl==1.11.1
# via aiohttp
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -445,7 +445,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_2_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -393,7 +393,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_2_2_and_flask.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -440,7 +440,7 @@ wtforms==3.1.2
# via flask-admin
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_3_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -399,7 +399,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_3_2_and_flask.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -446,7 +446,7 @@ wtforms==3.1.2
# via flask-admin
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_4_0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -399,7 +399,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_4_0_and_flask.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -446,7 +446,7 @@ wtforms==3.1.2
# via flask-admin
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_4_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -399,7 +399,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_4_1_and_flask.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -446,7 +446,7 @@ wtforms==3.1.2
# via flask-admin
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_4_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -397,7 +397,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/django_4_2_and_flask.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -444,7 +444,7 @@ wtforms==3.1.2
# via flask-admin
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -450,7 +450,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/flask.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -396,7 +396,7 @@ wtforms==3.1.2
# via flask-admin
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/ml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -473,7 +473,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
4 changes: 2 additions & 2 deletions examples/requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pdf2image==1.17.0
# via -r examples/requirements/common.in
pdfkit==1.0.0
# via -r examples/requirements/common.in
pillow==9.5.0
pillow==11.0.0
# via
# pdf2image
# python-pptx
Expand Down Expand Up @@ -399,7 +399,7 @@ werkzeug==3.0.4
# via moto
xlsxwriter==3.2.0
# via python-pptx
xml2epub==2.6.5
xml2epub==2.6.6
# via -r examples/requirements/common.in
xmltodict==0.13.0
# via moto
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def clean_readme(text: str) -> str:
return text


version = "0.17.12"
version = "0.17.13"

try:
readme = open(os.path.join(os.path.dirname(__file__), "README.rst")).read()
Expand Down Expand Up @@ -108,8 +108,8 @@ def clean_readme(text: str) -> str:
long_description_content_type="text/x-rst",
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
# "Programming Language :: Python :: 3.7",
# "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
2 changes: 1 addition & 1 deletion src/faker_file/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "faker_file"
__version__ = "0.17.12"
__version__ = "0.17.13"
__author__ = "Artur Barseghyan <[email protected]>"
__copyright__ = "2022-2024 Artur Barseghyan"
__license__ = "MIT"
25 changes: 21 additions & 4 deletions src/faker_file/contrib/pdf_file/pil_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,18 @@ def add_paragraph(
y_text = position[1]
# LOGGER.debug(f"position: {position}")
for counter, line in enumerate(lines):
text_width, text_height = generator.draw.textsize(
line, font=font, spacing=generator.spacing
# text_width, text_height = generator.draw.textsize(
# line, font=font, spacing=generator.spacing
# )
text_bbox = generator.draw.textbbox(
(position[0], y_text),
line,
font=font,
spacing=generator.spacing,
)
# text_width = text_bbox[2] - text_bbox[0]
text_height = text_bbox[3] - text_bbox[1]

if y_text + text_height > generator.page_height:
generator.save_and_start_new_page()
y_text = 0
Expand Down Expand Up @@ -369,7 +378,11 @@ def add_heading(
font=font,
)

text_width, text_height = generator.draw.textsize(_content, font=font)
# text_width, text_height = generator.draw.textsize(_content, font=font)
text_bbox = generator.draw.textbbox((position[0], y), _content, font=font)
# text_width = text_bbox[2] - text_bbox[0]
text_height = text_bbox[3] - text_bbox[1]

y += text_height

# If you want to keep track of the last position to place another
Expand Down Expand Up @@ -450,7 +463,11 @@ def draw_table_cell(document, cell_content, position, cell_size, font):
)

# Draw text in the rectangle
text_width, text_height = document.textsize(cell_content, font=font)
# text_width, text_height = document.textsize(cell_content, font=font)
text_bbox = document.textbbox((0, 0), cell_content, font=font)
text_width = text_bbox[2] - text_bbox[0]
text_height = text_bbox[3] - text_bbox[1]

text_position = (
x + (width - text_width) // 2,
y + (height - text_height) // 2,
Expand Down
Loading
Loading