Skip to content

Commit

Permalink
Update xhtml2pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
timobrembeck committed Feb 24, 2023
1 parent ea9b69d commit 988cd16
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
UNRELEASED
----------

* [ [#1498](https://github.com/digitalfabrik/integreat-cms/issues/1498) ] Fix PDF errors on specific pages in Arabic & Farsi


2023.2.2
--------
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies = [
"rules",
"six",
"webauthn",
"xhtml2pdf==0.2.8",
"xhtml2pdf",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -157,10 +157,10 @@ pinned = [
"pydantic==1.10.5",
"Pygments==2.14.0",
"pyHanko==0.17.0",
"pyhanko-certvalidator==0.20.0",
"pyhanko-certvalidator==0.20.1",
"pyOpenSSL==23.0.0",
"pyotp==2.8.0",
"PyPDF3==1.0.6",
"pypdf==3.4.1",
"pypng==0.20220715.0",
"pyrsistent==0.19.3",
"python-bidi==0.4.2",
Expand All @@ -180,7 +180,6 @@ pinned = [
"stack-data==0.6.2",
"svglib==1.5.1",
"tinycss2==1.2.1",
"tqdm==4.64.1",
"traitlets==5.9.0",
"typing_extensions==4.5.0",
"tzdata==2022.7",
Expand All @@ -190,7 +189,7 @@ pinned = [
"wcwidth==0.2.6",
"webauthn==1.7.2",
"webencodings==0.5.1",
"xhtml2pdf==0.2.8",
"xhtml2pdf==0.2.9",
"yarl==1.8.2",
]

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/pdf/files/6262976c99/Integreat - Deutsch - Willkommen.pdf
Binary file not shown.
Binary file modified tests/pdf/files/92ff67bd01/Integreat - Deutsch - Augsburg.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/pdf/files/e155c5e38b/Integreat - Englisch - Welcome.pdf
Binary file not shown.
27 changes: 12 additions & 15 deletions tests/pdf/test_pdf_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from urllib.parse import urlencode, quote

import pytest
import PyPDF3
import pypdf

from django.urls import reverse

Expand Down Expand Up @@ -107,25 +107,22 @@ def test_pdf_export(
print(response.headers)
assert response.headers.get("Content-Type") == "application/pdf"
# Compare file content
result_pdf = PyPDF3.PdfFileReader(
io.BytesIO(b"".join(response.streaming_content))
)
result_pdf = pypdf.PdfReader(io.BytesIO(b"".join(response.streaming_content)))
# pylint: disable=consider-using-with
expected_pdf = PyPDF3.PdfFileReader(
expected_pdf = pypdf.PdfReader(
open(f"tests/pdf/files/{expected_filename}", "rb")
)
# Assert that both documents have same number of pages
assert result_pdf.numPages == expected_pdf.numPages
assert len(result_pdf.pages) == len(expected_pdf.pages)
# Assert that the content is identical
for page_number in range(result_pdf.numPages):
result_page = result_pdf.getPage(page_number)
expected_page = expected_pdf.getPage(page_number)
assert result_page.artBox == expected_page.artBox
assert result_page.bleedBox == expected_page.bleedBox
assert result_page.cropBox == expected_page.cropBox
assert result_page.mediaBox == expected_page.mediaBox
assert result_page.extractText() == expected_page.extractText()
assert result_page.getContents() == expected_page.getContents()
for page_number, result_page in enumerate(result_pdf.pages):
expected_page = expected_pdf.pages[page_number]
assert result_page.artbox == expected_page.artbox
assert result_page.bleedbox == expected_page.bleedbox
assert result_page.cropbox == expected_page.cropbox
assert result_page.mediabox == expected_page.mediabox
assert result_page.extract_text() == expected_page.extract_text()
assert result_page.get_contents() == expected_page.get_contents()


# pylint: disable=unused-argument,too-many-locals
Expand Down

0 comments on commit 988cd16

Please sign in to comment.