Skip to content

Commit fbf4c39

Browse files
authored
Merge bc9345a into 98f46b1
2 parents 98f46b1 + bc9345a commit fbf4c39

File tree

88 files changed

+1630
-1597
lines changed

Some content is hidden

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

88 files changed

+1630
-1597
lines changed

.github/workflows/continuous-integration-workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
sed -i "s/author:.*/author: v$(python setup.py -V 2>/dev/null)/" mkdocs.yml
7676
cp tutorial/notebook.ipynb docs/
7777
mkdocs build
78-
pdoc --html -o public/ fpdf
78+
pdoc --html -o public/ fpdf --config "git_link_template='https://github.com/PyFPDF/fpdf2/blob/{commit}/{path}#L{start_line}-L{end_line}'"
7979
cd contributors/ && PYTHONUNBUFFERED=1 ./build_contributors_html_page.py PyFPDF/fpdf2
8080
cp -t ../public/ contributors.html contributors-map-small.png
8181
- name: Deploy documentation 🚀

CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ in order to get warned about deprecated features used in your code.
1616

1717
This can also be enabled programmatically with `warnings.simplefilter('default', DeprecationWarning)`.
1818

19-
## [2.6.2] - Not released yet
19+
## [2.7.0] - Not released yet
2020
### Added
21-
* [`FPDF.multi_cell()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.multi_cell) and [`FPDF.write()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write) now accept a `wrapmode` argument for word or character based line wrapping ("WORD"/"CHAR").
21+
- new method [`FPDF.table()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.table): [documentation](https://pyfpdf.github.io/fpdf2/Tables.html)
2222
- [`FPDF.image()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.image) has a new `keep_aspect_ratio` optional boolean parameter, to fit it inside a given rectangle: [documentation](https://pyfpdf.github.io/fpdf2/Images.html#fitting-an-image-inside-a-rectangle)
23-
- new method `FPDF.preload_image()`: [documentation](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.preload_image)
23+
- [`FPDF.multi_cell()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.multi_cell) and [`FPDF.write()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write) now accept a `wrapmode` argument for word or character based line wrapping ("WORD"/"CHAR").
24+
- new methods: [`FPDF.preload_image()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.preload_image) & [`FPDF.use_font_style()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.use_font_style)
2425
- new translation of the tutorial in [简体中文](https://pyfpdf.github.io/fpdf2/Tutorial-zh.html) - thanks to @Bubbu0129
2526
- new method [`FPDF.set_fallback_fonts()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.set_fallback_fonts) allow alternative fonts to be provided if a character on the text is not available on the currently set font - thanks to @andersonhc
2627
- documentation on how to embed static [Plotly](https://plotly.com/python/) charts: [link to docs](https://pyfpdf.github.io/fpdf2/Maths.html)
@@ -32,10 +33,13 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
3233
- all `TitleStyle` constructor parameters are now effectively optional
3334
- memory usage was reduced by 10 MiB in some cases, thanks to a small optimization in using `fonttools`
3435
### Changed
36+
* [`FPDF.write_html()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html) now uses the new [`FPDF.table()`](https://pyfpdf.github.io/fpdf2/Tables.html) method to render `<table>` tags. As a consequence, vertical space before `<table>` tags has sometimes been reduced.
3537
- vector images parsing is now more robust: `fpdf2` can now embed SVG files without `viewPort` or no `height` / `width`
3638
- bitonal images are now encoded using `CCITTFaxDecode`, reducing their size in the PDF document - thanks to @eroux
3739
- when possible, JPG and group4 encoded TIFFs are now embedded directly without recompression - thanks to @eroux
3840
- ICC Profiles of included images are now extracted and turned into PDF objects; they should now be taken into account by PDF viewers - thanks to @eroux
41+
### Removed
42+
* [`FPDF.write_html()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html) now uses the new [`FPDF.table()`](https://pyfpdf.github.io/fpdf2/Tables.html) method to render `<table>` tags. As a consequence, it does not support the `height` attribute defined on `<td>` / `<th>` tags anymore, nor `height` / `width` attributes defined on `<img>` tags inside cells, nor `width` attributes defined on `<thead>` / `<tfoot>` tags.
3943

4044
## [2.6.1] - 2023-01-13
4145
### Added

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pip install git+https://github.com/PyFPDF/fpdf2.git@master
6464
* Embedding images, including transparency and alpha channel
6565
* Arbitrary path drawing and basic [SVG](https://pyfpdf.github.io/fpdf2/SVG.html) import
6666
* Embedding [barcodes](https://pyfpdf.github.io/fpdf2/Barcodes.html), [charts & graphs](https://pyfpdf.github.io/fpdf2/Maths.html), [emojis, symbols & dingbats](https://pyfpdf.github.io/fpdf2/EmojisSymbolsDingbats.html)
67-
* [Cell / multi-cell / plaintext writing](https://pyfpdf.github.io/fpdf2/Text.html), with [automatic page breaks](https://pyfpdf.github.io/fpdf2/PageBreaks.html), line break and text justification
67+
* [Tables](https://pyfpdf.github.io/fpdf2/Tables.html) and also [cell / multi-cell / plaintext writing](https://pyfpdf.github.io/fpdf2/Text.html), with [automatic page breaks](https://pyfpdf.github.io/fpdf2/PageBreaks.html), line break and text justification
6868
* Choice of measurement unit, page format & margins. Optional page header and footer
6969
* Basic [conversion from HTML to PDF](https://pyfpdf.github.io/fpdf2/HTML.html)
7070
* A [templating system](https://pyfpdf.github.io/fpdf2/Templates.html) to render PDFs in batchs

docs/Images.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ When you want to scale an image to fill a rectangle, while keeping its aspect ra
5656
and ensuring it does **not** overflow the rectangle width nor height in the process,
5757
you can set `w` / `h` and also provide `keep_aspect_ratio=True` to the [`image()`](fpdf/fpdf.html#fpdf.fpdf.FPDF.image) method.
5858

59-
The following unit test illustrates that:
59+
The following unit tests illustrate that:
6060

6161
* [test_image_fit.py](https://github.com/PyFPDF/fpdf2/blob/master/test/image/test_image_fit.py)
6262
* resulting document: [image_fit_in_rect.pdf](https://github.com/PyFPDF/fpdf2/blob/master/test/image/image_fit_in_rect.pdf)

docs/Maths.md

+11-16
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,20 @@ columns = [list(df)] # Get list of dataframe columns
128128
rows = df.values.tolist() # Get list of dataframe rows
129129
data = columns + rows # Combine columns and rows in one list
130130

131-
# Start pdf creating
132131
pdf = FPDF()
133132
pdf.add_page()
134133
pdf.set_font("Times", size=10)
135-
line_height = pdf.font_size * 2.5
136-
col_width = pdf.epw / 4 # distribute content evenly
137-
138-
for row in data:
139-
for datum in row:
140-
pdf.multi_cell(
141-
col_width,
142-
line_height,
143-
datum,
144-
border=1,
145-
new_y="TOP",
146-
max_line_height=pdf.font_size,
147-
)
148-
pdf.ln(line_height)
149-
pdf.output("table_with_cells.pdf")
134+
with pdf.table(borders_layout="MINIMAL",
135+
cell_fill_color=200, # grey
136+
cell_fill_mode="ROWS",
137+
line_height=pdf.font_size * 2.5,
138+
text_align="CENTER",
139+
width=160) as table:
140+
for data_row in data:
141+
row = table.row()
142+
for datum in data_row:
143+
row.cell(datum)
144+
pdf.output("table_from_pandas.pdf")
150145
```
151146

152147
Result:

0 commit comments

Comments
 (0)