xhtml2pdf 0.2.25__tar.gz → 0.2.26__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {xhtml2pdf-0.2.25/xhtml2pdf.egg-info → xhtml2pdf-0.2.26}/PKG-INFO +2 -206
  2. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/pyproject.toml +3 -3
  3. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_page_numbering.py +33 -0
  4. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_tags.py +95 -1
  5. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/__init__.py +1 -1
  6. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/block.py +8 -3
  7. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/flex.py +9 -4
  8. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/charts.py +118 -25
  9. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/context.py +22 -3
  10. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/tags.py +16 -3
  11. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/xhtml2pdf_reportlab.py +23 -0
  12. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26/xhtml2pdf.egg-info}/PKG-INFO +2 -206
  13. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf.egg-info/SOURCES.txt +0 -1
  14. xhtml2pdf-0.2.25/AUTHORS.rst +0 -60
  15. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/LICENSE.txt +0 -0
  16. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/MANIFEST.in +0 -0
  17. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/README.rst +0 -0
  18. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/setup.cfg +0 -0
  19. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_asian_font_support.py +0 -0
  20. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_bidi.py +0 -0
  21. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_block_box.py +0 -0
  22. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_block_margins.py +0 -0
  23. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_block_width.py +0 -0
  24. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_cli.py +0 -0
  25. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_css_media_rule.py +0 -0
  26. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_css_parser.py +0 -0
  27. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_css_variables.py +0 -0
  28. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_document.py +0 -0
  29. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_files.py +0 -0
  30. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_flex.py +0 -0
  31. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_flex_flowable.py +0 -0
  32. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_flex_layout.py +0 -0
  33. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_font_isolation.py +0 -0
  34. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_fonts.py +0 -0
  35. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_frame_align.py +0 -0
  36. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_frame_pages.py +0 -0
  37. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_http.py +0 -0
  38. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_inline_block.py +0 -0
  39. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_inline_box.py +0 -0
  40. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_optional_dependencies.py +0 -0
  41. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_page_padding.py +0 -0
  42. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_paragraph.py +0 -0
  43. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_paragraph_height.py +0 -0
  44. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_parser.py +0 -0
  45. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_pdf.py +0 -0
  46. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_position.py +0 -0
  47. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_reportlab.py +0 -0
  48. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_reportlab_api.py +0 -0
  49. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_reportlab_paragraph.py +0 -0
  50. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_resource_policy.py +0 -0
  51. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_right_to_left_font_support.py +0 -0
  52. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_security_limits.py +0 -0
  53. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_selectors.py +0 -0
  54. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_signatures.py +0 -0
  55. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_special_css.py +0 -0
  56. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_table_border_radius.py +0 -0
  57. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_table_css.py +0 -0
  58. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_tables.py +0 -0
  59. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_update_face_name.py +0 -0
  60. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_utils.py +0 -0
  61. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_watermarks.py +0 -0
  62. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_word_breaking.py +0 -0
  63. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/tests/test_wsgi.py +0 -0
  64. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/__main__.py +0 -0
  65. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/_bidi_data.py +0 -0
  66. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/bidi.py +0 -0
  67. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/__init__.py +0 -0
  68. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/flex_layout.py +0 -0
  69. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/position.py +0 -0
  70. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/signs.py +0 -0
  71. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/builders/watermarks.py +0 -0
  72. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/config/__init__.py +0 -0
  73. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/config/httpconfig.py +0 -0
  74. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/config/resources.py +0 -0
  75. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/default.py +0 -0
  76. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/document.py +0 -0
  77. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/files.py +0 -0
  78. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/paragraph.py +0 -0
  79. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/parser.py +0 -0
  80. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/pdf.py +0 -0
  81. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/pisa.py +0 -0
  82. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/properties.py +0 -0
  83. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/reportlab_paragraph.py +0 -0
  84. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/tables.py +0 -0
  85. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/util.py +0 -0
  86. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/w3c/__init__.py +0 -0
  87. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/w3c/css.py +0 -0
  88. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/w3c/cssDOMElementInterface.py +0 -0
  89. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/w3c/cssParser.py +0 -0
  90. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/w3c/cssSpecial.py +0 -0
  91. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/w3c/css_variables.py +0 -0
  92. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf/wsgi.py +0 -0
  93. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf.egg-info/dependency_links.txt +0 -0
  94. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf.egg-info/entry_points.txt +0 -0
  95. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf.egg-info/requires.txt +0 -0
  96. {xhtml2pdf-0.2.25 → xhtml2pdf-0.2.26}/xhtml2pdf.egg-info/top_level.txt +0 -0
@@ -1,218 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xhtml2pdf
3
- Version: 0.2.25
3
+ Version: 0.2.26
4
4
  Summary: PDF generator using HTML and CSS
5
5
  Author-email: Dirk Holtwick <dirk.holtwick@gmail.com>
6
6
  Maintainer-email: Luis Zarate <luisza14@gmail.com>, Timo Brembeck <opensource@timo.brembeck.email>
7
- License:
8
- Apache License
9
- Version 2.0, January 2004
10
- http://www.apache.org/licenses/
11
-
12
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
13
-
14
- 1. Definitions.
15
-
16
- "License" shall mean the terms and conditions for use, reproduction,
17
- and distribution as defined by Sections 1 through 9 of this document.
18
-
19
- "Licensor" shall mean the copyright owner or entity authorized by
20
- the copyright owner that is granting the License.
21
-
22
- "Legal Entity" shall mean the union of the acting entity and all
23
- other entities that control, are controlled by, or are under common
24
- control with that entity. For the purposes of this definition,
25
- "control" means (i) the power, direct or indirect, to cause the
26
- direction or management of such entity, whether by contract or
27
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
28
- outstanding shares, or (iii) beneficial ownership of such entity.
29
-
30
- "You" (or "Your") shall mean an individual or Legal Entity
31
- exercising permissions granted by this License.
32
-
33
- "Source" form shall mean the preferred form for making modifications,
34
- including but not limited to software source code, documentation
35
- source, and configuration files.
36
-
37
- "Object" form shall mean any form resulting from mechanical
38
- transformation or translation of a Source form, including but
39
- not limited to compiled object code, generated documentation,
40
- and conversions to other media types.
41
-
42
- "Work" shall mean the work of authorship, whether in Source or
43
- Object form, made available under the License, as indicated by a
44
- copyright notice that is included in or attached to the work
45
- (an example is provided in the Appendix below).
46
-
47
- "Derivative Works" shall mean any work, whether in Source or Object
48
- form, that is based on (or derived from) the Work and for which the
49
- editorial revisions, annotations, elaborations, or other modifications
50
- represent, as a whole, an original work of authorship. For the purposes
51
- of this License, Derivative Works shall not include works that remain
52
- separable from, or merely link (or bind by name) to the interfaces of,
53
- the Work and Derivative Works thereof.
54
-
55
- "Contribution" shall mean any work of authorship, including
56
- the original version of the Work and any modifications or additions
57
- to that Work or Derivative Works thereof, that is intentionally
58
- submitted to Licensor for inclusion in the Work by the copyright owner
59
- or by an individual or Legal Entity authorized to submit on behalf of
60
- the copyright owner. For the purposes of this definition, "submitted"
61
- means any form of electronic, verbal, or written communication sent
62
- to the Licensor or its representatives, including but not limited to
63
- communication on electronic mailing lists, source code control systems,
64
- and issue tracking systems that are managed by, or on behalf of, the
65
- Licensor for the purpose of discussing and improving the Work, but
66
- excluding communication that is conspicuously marked or otherwise
67
- designated in writing by the copyright owner as "Not a Contribution."
68
-
69
- "Contributor" shall mean Licensor and any individual or Legal Entity
70
- on behalf of whom a Contribution has been received by Licensor and
71
- subsequently incorporated within the Work.
72
-
73
- 2. Grant of Copyright License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- copyright license to reproduce, prepare Derivative Works of,
77
- publicly display, publicly perform, sublicense, and distribute the
78
- Work and such Derivative Works in Source or Object form.
79
-
80
- 3. Grant of Patent License. Subject to the terms and conditions of
81
- this License, each Contributor hereby grants to You a perpetual,
82
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
- (except as stated in this section) patent license to make, have made,
84
- use, offer to sell, sell, import, and otherwise transfer the Work,
85
- where such license applies only to those patent claims licensable
86
- by such Contributor that are necessarily infringed by their
87
- Contribution(s) alone or by combination of their Contribution(s)
88
- with the Work to which such Contribution(s) was submitted. If You
89
- institute patent litigation against any entity (including a
90
- cross-claim or counterclaim in a lawsuit) alleging that the Work
91
- or a Contribution incorporated within the Work constitutes direct
92
- or contributory patent infringement, then any patent licenses
93
- granted to You under this License for that Work shall terminate
94
- as of the date such litigation is filed.
95
-
96
- 4. Redistribution. You may reproduce and distribute copies of the
97
- Work or Derivative Works thereof in any medium, with or without
98
- modifications, and in Source or Object form, provided that You
99
- meet the following conditions:
100
-
101
- (a) You must give any other recipients of the Work or
102
- Derivative Works a copy of this License; and
103
-
104
- (b) You must cause any modified files to carry prominent notices
105
- stating that You changed the files; and
106
-
107
- (c) You must retain, in the Source form of any Derivative Works
108
- that You distribute, all copyright, patent, trademark, and
109
- attribution notices from the Source form of the Work,
110
- excluding those notices that do not pertain to any part of
111
- the Derivative Works; and
112
-
113
- (d) If the Work includes a "NOTICE" text file as part of its
114
- distribution, then any Derivative Works that You distribute must
115
- include a readable copy of the attribution notices contained
116
- within such NOTICE file, excluding those notices that do not
117
- pertain to any part of the Derivative Works, in at least one
118
- of the following places: within a NOTICE text file distributed
119
- as part of the Derivative Works; within the Source form or
120
- documentation, if provided along with the Derivative Works; or,
121
- within a display generated by the Derivative Works, if and
122
- wherever such third-party notices normally appear. The contents
123
- of the NOTICE file are for informational purposes only and
124
- do not modify the License. You may add Your own attribution
125
- notices within Derivative Works that You distribute, alongside
126
- or as an addendum to the NOTICE text from the Work, provided
127
- that such additional attribution notices cannot be construed
128
- as modifying the License.
129
-
130
- You may add Your own copyright statement to Your modifications and
131
- may provide additional or different license terms and conditions
132
- for use, reproduction, or distribution of Your modifications, or
133
- for any such Derivative Works as a whole, provided Your use,
134
- reproduction, and distribution of the Work otherwise complies with
135
- the conditions stated in this License.
136
-
137
- 5. Submission of Contributions. Unless You explicitly state otherwise,
138
- any Contribution intentionally submitted for inclusion in the Work
139
- by You to the Licensor shall be under the terms and conditions of
140
- this License, without any additional terms or conditions.
141
- Notwithstanding the above, nothing herein shall supersede or modify
142
- the terms of any separate license agreement you may have executed
143
- with Licensor regarding such Contributions.
144
-
145
- 6. Trademarks. This License does not grant permission to use the trade
146
- names, trademarks, service marks, or product names of the Licensor,
147
- except as required for reasonable and customary use in describing the
148
- origin of the Work and reproducing the content of the NOTICE file.
149
-
150
- 7. Disclaimer of Warranty. Unless required by applicable law or
151
- agreed to in writing, Licensor provides the Work (and each
152
- Contributor provides its Contributions) on an "AS IS" BASIS,
153
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
154
- implied, including, without limitation, any warranties or conditions
155
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
156
- PARTICULAR PURPOSE. You are solely responsible for determining the
157
- appropriateness of using or redistributing the Work and assume any
158
- risks associated with Your exercise of permissions under this License.
159
-
160
- 8. Limitation of Liability. In no event and under no legal theory,
161
- whether in tort (including negligence), contract, or otherwise,
162
- unless required by applicable law (such as deliberate and grossly
163
- negligent acts) or agreed to in writing, shall any Contributor be
164
- liable to You for damages, including any direct, indirect, special,
165
- incidental, or consequential damages of any character arising as a
166
- result of this License or out of the use or inability to use the
167
- Work (including but not limited to damages for loss of goodwill,
168
- work stoppage, computer failure or malfunction, or any and all
169
- other commercial damages or losses), even if such Contributor
170
- has been advised of the possibility of such damages.
171
-
172
- 9. Accepting Warranty or Additional Liability. While redistributing
173
- the Work or Derivative Works thereof, You may choose to offer,
174
- and charge a fee for, acceptance of support, warranty, indemnity,
175
- or other liability obligations and/or rights consistent with this
176
- License. However, in accepting such obligations, You may act only
177
- on Your own behalf and on Your sole responsibility, not on behalf
178
- of any other Contributor, and only if You agree to indemnify,
179
- defend, and hold each Contributor harmless for any liability
180
- incurred by, or claims asserted against, such Contributor by reason
181
- of your accepting any such warranty or additional liability.
182
-
183
- END OF TERMS AND CONDITIONS
184
-
185
- APPENDIX: How to apply the Apache License to your work.
186
-
187
- To apply the Apache License to your work, attach the following
188
- boilerplate notice, with the fields enclosed by brackets "[]"
189
- replaced with your own identifying information. (Don't include
190
- the brackets!) The text should be enclosed in the appropriate
191
- comment syntax for the file format. We also recommend that a
192
- file or class name and description of purpose be included on the
193
- same "printed page" as the copyright notice for easier
194
- identification within third-party archives.
195
-
196
- Copyright [yyyy] [name of copyright owner]
197
-
198
- Licensed under the Apache License, Version 2.0 (the "License");
199
- you may not use this file except in compliance with the License.
200
- You may obtain a copy of the License at
201
-
202
- http://www.apache.org/licenses/LICENSE-2.0
203
-
204
- Unless required by applicable law or agreed to in writing, software
205
- distributed under the License is distributed on an "AS IS" BASIS,
206
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
207
- See the License for the specific language governing permissions and
208
- limitations under the License.
209
-
7
+ License-Expression: Apache-2.0
210
8
  Project-URL: Repository, https://github.com/xhtml2pdf/xhtml2pdf
211
9
  Project-URL: Bug tracker, https://github.com/xhtml2pdf/xhtml2pdf/issues
212
10
  Project-URL: Documentation, https://xhtml2pdf.readthedocs.io/
213
11
  Project-URL: Changelog, https://xhtml2pdf.readthedocs.io/en/latest/release-notes.html
214
12
  Keywords: PDF,HTML,HTML,XML,CSS
215
- Classifier: License :: OSI Approved :: Apache Software License
216
13
  Classifier: Development Status :: 4 - Beta
217
14
  Classifier: Environment :: Console
218
15
  Classifier: Environment :: Other Environment
@@ -242,7 +39,6 @@ Classifier: Topic :: Utilities
242
39
  Requires-Python: >=3.10
243
40
  Description-Content-Type: text/x-rst
244
41
  License-File: LICENSE.txt
245
- License-File: AUTHORS.rst
246
42
  Requires-Dist: arabic-reshaper>=3.0.0
247
43
  Requires-Dist: html5lib>=1.1
248
44
  Requires-Dist: Pillow>=8.1.1
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools"]
2
+ requires = ["setuptools>=77"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
 
@@ -15,9 +15,9 @@ maintainers = [
15
15
  description = "PDF generator using HTML and CSS"
16
16
  keywords = ["PDF", "HTML", "HTML", "XML", "CSS"]
17
17
  readme = "README.rst"
18
- license = {file = "LICENSE.txt"}
18
+ license = "Apache-2.0"
19
+ license-files = ["LICENSE.txt"]
19
20
  classifiers = [
20
- "License :: OSI Approved :: Apache Software License",
21
21
  "Development Status :: 4 - Beta",
22
22
  "Environment :: Console",
23
23
  "Environment :: Other Environment",
@@ -8,6 +8,7 @@ number of pages in the document.
8
8
  """
9
9
 
10
10
  from io import BytesIO
11
+ from typing import ClassVar
11
12
  from unittest import TestCase
12
13
 
13
14
  from pypdf import PdfReader
@@ -78,3 +79,35 @@ class PageCountInTheFlowTest(TestCase):
78
79
  texts = page_texts("<p>count <pdf:pagecount/></p>" + FILLER)
79
80
  self.assertGreater(len(texts), 1)
80
81
  self.assertIn(f"count {len(texts)}", texts[0])
82
+
83
+
84
+ class PageFieldsInsideABoxTest(TestCase):
85
+ """A box or a cell lays its lines out before it draws what is in it."""
86
+
87
+ CONTAINERS: ClassVar[dict[str, str]] = {
88
+ "a bordered block": (
89
+ "<div style='border: 1pt solid red; padding: 4pt'><p>{}</p></div>"
90
+ ),
91
+ "a block with a width": "<div style='width: 50%'>{}</div>",
92
+ "a table cell": "<table><tr><td>{}</td></tr></table>",
93
+ "a flex item": "<div style='display: flex'><div>{}</div></div>",
94
+ }
95
+
96
+ def test_the_number_and_the_count_are_there(self) -> None:
97
+ for name, container in self.CONTAINERS.items():
98
+ with self.subTest(name):
99
+ texts = page_texts(
100
+ container.format("page <pdf:pagenumber/> of <pdf:pagecount/>")
101
+ + "<pdf:nextpage/>"
102
+ + container.format("then <pdf:pagenumber/> of <pdf:pagecount/>")
103
+ )
104
+ self.assertIn("page 1 of 2", texts[0])
105
+ self.assertIn("then 2 of 2", texts[1])
106
+
107
+ def test_a_renumbered_page_in_a_box(self) -> None:
108
+ box = self.CONTAINERS["a bordered block"]
109
+ texts = page_texts(
110
+ "<p>cover</p><pdf:nextpage/><pdf:resetpagenumber value='1'/>"
111
+ + box.format("numbered <pdf:pagenumber/>")
112
+ )
113
+ self.assertIn("numbered 1", texts[1])
@@ -1,6 +1,7 @@
1
1
  import base64
2
2
  import hashlib
3
3
  import io
4
+ import logging
4
5
  import re
5
6
  from pathlib import Path
6
7
  from typing import NamedTuple
@@ -13,6 +14,7 @@ from pypdf.generic import ArrayObject
13
14
  from reportlab.pdfbase.pdfmetrics import stringWidth
14
15
 
15
16
  from xhtml2pdf import pisa, tags
17
+ from xhtml2pdf.charts import HorizontalLine
16
18
  from xhtml2pdf.context import pisaContext
17
19
  from xhtml2pdf.document import pisaStory
18
20
  from xhtml2pdf.parser import AttrContainer, pisaGetAttributes
@@ -144,7 +146,7 @@ class BadInputKeepsTheDocumentTestCase(TestCase):
144
146
  with self.assertNoLogs("xhtml2pdf", level="WARNING"):
145
147
  result = self.convert(
146
148
  '<canvas type="graph" width="200" height="100">'
147
- '{"type": "pie", "data": [[1, 2]], "labels": ["a", "b"]}</canvas>'
149
+ '{"type": "pie", "data": [1, 2], "labels": ["a", "b"]}</canvas>'
148
150
  )
149
151
  self.assertEqual(0, result.err)
150
152
 
@@ -386,6 +388,91 @@ class ChartParametersTestCase(TestCase):
386
388
  self.assertEqual(["a", "1", "b", "2", "c", "3"], labels[:6])
387
389
 
388
390
 
391
+ class ChartWarningsTestCase(TestCase):
392
+ """A chart property that does nothing says so."""
393
+
394
+ @staticmethod
395
+ def render(chart: str) -> None:
396
+ pisa.pisaDocument(
397
+ io.StringIO(
398
+ f'<html><body><canvas type="graph" width="300" height="150">{chart}'
399
+ "</canvas></body></html>"
400
+ ),
401
+ io.BytesIO(),
402
+ )
403
+
404
+ def json_warnings(self, chart: str) -> list[str]:
405
+ """What is said about the chart's JSON, and only that."""
406
+ found: list[str] = []
407
+ handler = logging.Handler(logging.WARNING)
408
+ handler.emit = lambda record: found.append(record.getMessage())
409
+ logger = logging.getLogger("xhtml2pdf")
410
+ level = logger.level
411
+ logger.addHandler(handler)
412
+ logger.setLevel(logging.WARNING)
413
+ try:
414
+ self.render(chart)
415
+ finally:
416
+ logger.removeHandler(handler)
417
+ logger.setLevel(level)
418
+ return [line for line in found if "in the JSON of" in line]
419
+
420
+ def warnings(self, chart: str) -> list[str]:
421
+ found = self.json_warnings(chart)
422
+ self.assertTrue(found)
423
+ return found
424
+
425
+ def test_a_key_the_chart_does_not_read(self) -> None:
426
+ (line,) = self.warnings(
427
+ '{"type": "verticalbar", "data": [[1, 2]], "labels": ["a", "b"],'
428
+ ' "barThickness": 5, "legend": {"x": 1, "colour": "red"}}'
429
+ )
430
+ self.assertIn("'barThickness'", line)
431
+ self.assertIn("'legend.colour'", line)
432
+
433
+ def test_a_value_the_property_does_not_take(self) -> None:
434
+ (line,) = self.warnings(
435
+ '{"type": "verticalbar", "data": [[1, 2]], "labels": ["a", "b"],'
436
+ ' "barWidth": "wide"}'
437
+ )
438
+ self.assertIn("'barWidth'", line)
439
+ self.assertIn("'wide'", line)
440
+
441
+ def test_a_line_chart_takes_its_category_axis(self) -> None:
442
+ chart = HorizontalLine()
443
+ chart.set_properties(
444
+ {
445
+ "data": [[1, 2, 3]],
446
+ "labels": ["a", "b", "c"],
447
+ "categoryAxis": {"strokeColor": "red", "labels": {"angle": 30}},
448
+ }
449
+ )
450
+ self.assertEqual(30, chart.categoryAxis.labels.angle)
451
+ self.assertEqual(
452
+ [],
453
+ self.json_warnings(
454
+ '{"type": "horizontalline", "data": [[1, 2, 3]],'
455
+ ' "labels": ["a", "b", "c"], "categoryAxis": {"labels": {"angle": 30}}}'
456
+ ),
457
+ )
458
+
459
+ def test_a_chart_that_uses_every_key_says_nothing(self) -> None:
460
+ for chart in (
461
+ (
462
+ '{"type": "verticalbar", "data": [[1, 2]], "labels": ["a", "b"],'
463
+ ' "barWidth": 5, "valueAxis": {"valueMin": 0},'
464
+ ' "categoryAxis": {"labels": {"angle": 30}}}'
465
+ ),
466
+ (
467
+ '{"type": "pie", "data": [3, 1], "labels": ["x", "y"],'
468
+ ' "title": {"_text": "T", "x": 10, "y": 10},'
469
+ ' "legend": {"x": 10, "y": 10}, "slices": {"strokeColor": "white"}}'
470
+ ),
471
+ ):
472
+ with self.subTest(chart):
473
+ self.assertEqual([], self.json_warnings(chart))
474
+
475
+
389
476
  class SelfClosingTocTestCase(TestCase):
390
477
  """
391
478
  <pdf:toc /> puts the table of contents where it is written.
@@ -579,6 +666,13 @@ class CanvasPlacementTestCase(TestCase):
579
666
  self.assertAlmostEqual(plain["a"][0] + 31, padded["a"][0], places=1)
580
667
  self.assertAlmostEqual(plain["a"][1] - 31, padded["a"][1], places=1)
581
668
 
669
+ def test_the_text_around_it_in_its_block_is_kept(self) -> None:
670
+ with self.assertNoLogs("xhtml2pdf", level="WARNING"):
671
+ found = self.runs(f"<div>lead {self.CHART} tail</div>")
672
+ # y grows up the page: the lead above the chart, the tail below it.
673
+ self.assertGreater(found["lead"][1], found["a"][1])
674
+ self.assertGreater(found["a"][1], found["tail"][1])
675
+
582
676
  def test_text_align_center_centres_it(self) -> None:
583
677
  plain = self.runs(self.CHART)
584
678
  centred = self.runs(f"<div style='text-align: center'>{self.CHART}</div>")
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "0.2.25"
15
+ __version__ = "0.2.26"
@@ -35,7 +35,12 @@ from xhtml2pdf.builders.flex import (
35
35
  )
36
36
  from xhtml2pdf.builders.position import PositionAnchor
37
37
  from xhtml2pdf.util import drawBoxBackground, drawBoxBorders, getSize, toList
38
- from xhtml2pdf.xhtml2pdf_reportlab import PmlKeepInFrame, PmlMaxHeightMixIn, opened_up
38
+ from xhtml2pdf.xhtml2pdf_reportlab import (
39
+ PmlKeepInFrame,
40
+ PmlMaxHeightMixIn,
41
+ layout_moment,
42
+ opened_up,
43
+ )
39
44
 
40
45
  if TYPE_CHECKING:
41
46
  from collections.abc import Sequence
@@ -162,7 +167,7 @@ class BlockBox(Flowable, PmlMaxHeightMixIn):
162
167
  #: next page whole when it does not fit, if a page can hold it.
163
168
  self.keep_together = keep_together
164
169
  self.keepWithNext = False
165
- self._key: float | None = None
170
+ self._key: tuple[float, int, int] | None = None
166
171
  self._entries: list[StackEntry] = []
167
172
  self._inner = 0.0
168
173
  self._stacked = 0.0
@@ -196,7 +201,7 @@ class BlockBox(Flowable, PmlMaxHeightMixIn):
196
201
  def wrap(self, availWidth: float, availHeight: float) -> tuple[float, float]:
197
202
  availHeight = self.setMaxHeight(availHeight)
198
203
  style = self.style
199
- key = round(availWidth, 2)
204
+ key = (round(availWidth, 2), *layout_moment(getattr(self, "canv", None)))
200
205
  if self._key != key:
201
206
  # Laid out once per width and never at a trial one: a table
202
207
  # turns its percentage columns into points as it is wrapped.
@@ -60,6 +60,7 @@ from xhtml2pdf.xhtml2pdf_reportlab import (
60
60
  PmlKeepInFrame,
61
61
  PmlMaxHeightMixIn,
62
62
  PmlParagraph,
63
+ layout_moment,
63
64
  )
64
65
 
65
66
  if TYPE_CHECKING:
@@ -680,7 +681,7 @@ class FlexContainer(Flowable, PmlMaxHeightMixIn):
680
681
  self.layout = FlexLayout()
681
682
  #: Per item, the stacked content at the width it was last measured.
682
683
  self._stacks: dict[int, tuple[float, list[StackEntry], float]] = {}
683
- self._cache_key: tuple[float, float] | None = None
684
+ self._cache_key: tuple[float, float, int, int] | None = None
684
685
  self._box: ABag | None = None
685
686
 
686
687
  # ~ Platypus protocol ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -851,7 +852,11 @@ class FlexContainer(Flowable, PmlMaxHeightMixIn):
851
852
 
852
853
  def wrap(self, availWidth: float, availHeight: float) -> tuple[float, float]:
853
854
  availHeight = self.setMaxHeight(availHeight)
854
- key = (round(availWidth, 2), round(availHeight, 2))
855
+ key = (
856
+ round(availWidth, 2),
857
+ round(availHeight, 2),
858
+ *layout_moment(getattr(self, "canv", None)),
859
+ )
855
860
  if self._cache_key == key and self._box is not None:
856
861
  return self.width, self.height
857
862
  canv = getattr(self, "canv", None)
@@ -1539,13 +1544,13 @@ class InlineBox(Flowable):
1539
1544
  self._box_width = 0.0
1540
1545
  self._box_height = 0.0
1541
1546
  self.last_baseline: float | None = None
1542
- self._cache_key: float | None = None
1547
+ self._cache_key: tuple[float, int, int] | None = None
1543
1548
 
1544
1549
  def identity(self, maxLen=None) -> str:
1545
1550
  return f"<InlineBox with {len(self.content)} flowables>"
1546
1551
 
1547
1552
  def wrap(self, availWidth: float, availHeight: float) -> tuple[float, float]:
1548
- key = round(availWidth, 2)
1553
+ key = (round(availWidth, 2), *layout_moment(getattr(self, "canv", None)))
1549
1554
  if self._cache_key == key:
1550
1555
  return self.width, self.height
1551
1556
  canv = getattr(self, "canv", None)