You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CHANGELOG.md
+6
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,12 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
21
21
*[`FPDF.fonts.FontFace`](https://py-pdf.github.io/fpdf2/fpdf/fonts.html#fpdf.fonts.FontFace): Now has a static `combine` method that allows overriding a default FontFace (e.g. for specific cells in a table). Unspecified properties of the override FontFace retain the values of the default.
22
22
### Changed
23
23
*[`FPDF.table()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.table): If cell styles are provided for cells in heading rows, combine the cell style as an override with the overall heading style.
24
+
* SVG importing now supports clipping paths, and `defs` tags anywhere in the SVG file
25
+
*[`TextColumns()`](https://py-pdf.github.io/fpdf2/TextColumns.html) can now have images inserted (both raster and vector).
26
+
*[`TextColumns()`](https://py-pdf.github.io/fpdf2/TextColumns.html) can now advance to the next column with the new `new_column()` method or a FORM_FEED character (`\u000c`) in the text.
27
+
### Fixed
28
+
* Previously set dash patterns were not transferred correctly to new pages.
29
+
* Inserted Vector images used to ignore the `keep_aspect_ratio` argument.
24
30
25
31
## [2.7.6] - 2023-10-11
26
32
This release is the first performed from the [@py-pdf GitHub org](https://github.com/py-pdf), where `fpdf2` migrated.
Copy file name to clipboardexpand all lines: docs/TextColumns.md
+14-1
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,25 @@ _New in [:octicons-tag-24: 2.7.6](https://github.com/py-pdf/fpdf2/blob/master/CH
7
7
8
8
The `FPDF.text_columns()` method allows to create columnar layouts, with one or several columns. Columns will always be of equal width.
9
9
10
+
### Parameters ###
11
+
10
12
Beyond the parameters common to all text regions, the following are available for text columns:
11
13
12
14
* l_margin (float, optional) - override the current left page margin.
13
15
* r_margin (float, optional) - override the current right page margin.
14
16
* ncols (float, optional) - the number of columns to generate (Default: 2).
15
17
* gutter (float, optional) - the horizontal space required between each two columns (Default 10).
18
+
* balance (bool, optional) - Create height balanced columns, starting at the current height and ending at approximately the same level.
19
+
20
+
### Methods ###
21
+
22
+
Text columns support all the standard text region methods like `.paragraph()`, `.write()`, `.ln()`, and `.render()`. In addition to that:
23
+
24
+
*`.new_column()` - End the current column and continue at the top of the next one.
25
+
26
+
A FORM_FEED character (`\u000c`) in the text will have the same effect as an explicit call to `.new_column()`,
27
+
28
+
Note that when used within balanced columns, switching to a new column manually will result in incorrect balancing.
16
29
17
30
18
31
#### Single-Column Example ####
@@ -85,7 +98,7 @@ with cols:
85
98
```
86
99

87
100
88
-
Note that column balancing only works reliably when the font size (specifically the line height) doesn't change. If parts of the text use a larger or smaller font than the rest, then the balancing will usually be out of whack. Contributions for a more refined balancing algorithm are welcome.
101
+
Note that column balancing only works reliably when the font size (specifically the line height) doesn't change, and if there are no images included. If parts of the text use a larger or smaller font than the rest, then the balancing will usually be out of whack. Contributions for a more refined balancing algorithm are welcome.
Copy file name to clipboardexpand all lines: docs/TextRegion.md
+19-5
Original file line number
Diff line number
Diff line change
@@ -44,12 +44,12 @@ The horizontal start position will be either at the current x position, if that
44
44
In both horizontal and vertical positioning, regions with multiple columns may follow additional rules and restrictions.
45
45
46
46
47
-
### Interaction between Regions ###
47
+
### Interaction Between Regions ###
48
48
49
49
Several region instances can exist at the same time. But only one of them can act as context manager at any given time. It is not currently possible to activate them recursively. But it is possible to use them intermittingly. This will probably most often make sense between a columnar region and a table or a graphic. You may have some running text ending at a given height, then insert a table/graphic, and finally continue the running text at the new height below the table within the existing column(s).
50
50
51
51
52
-
### Common parameters ###
52
+
### Common Parameters ###
53
53
54
54
All types of text regions have the following constructor parameters in common:
55
55
@@ -59,14 +59,17 @@ All types of text regions have the following constructor parameters in common:
59
59
* print_sh (bool, optional) - Treat a soft-hyphen (\\u00ad) as a printable character, instead of a line breaking opportunity. (Default: False)
60
60
* skip_leading_spaces (default: False) - This flag is primarily used by `write_html()`, but may also have other uses. It removes all space characters at the beginning of each line.
61
61
* wrapmode (default "WORD") -
62
+
* image (str or PIL.Image.Image or io.BytesIO, optional) - An image to add to the region. This is a convenience parameter for cases when no further text or images need to be added to the paragraph. If both "text" and "image" arguments are present, the text will be inserted first. (Default: None)
63
+
* image_fill_width (bool, optional) - Indicates whether to increase the size of the image to fill the width of the column. Larger images will always be reduced to column width. (Default: False)
62
64
63
65
All of those values can be overriden for each individual paragraph.
64
66
65
67
66
-
### Common methods ###
68
+
### Common Methods ###
67
69
68
-
*`.paragraph()`[see characteristics parameters below] - establish a new paragraph in the text. The text added to this paragraph will start on a new line.
70
+
*`.paragraph()`[see characteristic parameters below] - establish a new paragraph in the text. The text added to this paragraph will start on a new line.
69
71
*`.write(text: str, link: = None)` - write text to the region. This is only permitted when no explicit paragraph is currently active.
72
+
*`.image()`[see characteristic parameters below] - insert a vector or raster image in the region, flowing with the text like a paragraph.
70
73
*`.ln(h: float = None)` - Start a new line moving either by the current font height or by the parameter "h". Only permitted when no explicit paragraph is currently active.
71
74
*`.render()` - if the region is not used as a context manager with "with", this method must be called to actually process the added text.
72
75
@@ -87,9 +90,20 @@ For more typographical control, you can use the following arguments. Most of tho
87
90
Other than text regions, paragraphs should always be used as context managers and never be reused. Violating those rules may result in the entered text turning up on the page out of sequence.
88
91
89
92
90
-
### Possible future extensions
93
+
### Possible Future Extensions ###
91
94
92
95
Those features are currently not supported, but Pull Requests are welcome to implement them:
93
96
94
97
* per-paragraph indentation
95
98
* first-line indentation
99
+
100
+
101
+
## Images ##
102
+
103
+
_New in [:octicons-tag-24: 2.7.7](https://github.com/py-pdf/fpdf2/blob/master/CHANGELOG.md)_
104
+
105
+
Most arguments for inserting images into text regions are the same as for the `FPDF.image()` method, and have the same or equivalent meaning.
106
+
Since the image will be placed automatically, the "x" and "y" parameters are not available. The positioning can be controlled with "align", where the default is "LEFT", with the alternatives "RIGHT" and "CENTER".
107
+
If neither width nor height are specified, the image will be inserted with the size resulting from the PDF default resolution of 72 dpi. If the "fill_width" parameter is set to True, it increases the size to fill the full column width if necessary. If the image is wider than the column width, it will always be reduced in size proportionally.
108
+
The "top_margin" and "bottom_margin" parameters have the same effect as with text paragraphs.
Este recoge todo el texto, posiblemente en incrementos, y lo distribuye entre el número de columnas solicitadas, insertando automáticamente saltos de página según sea necesario. Nota que mientras la instancia de `TextColumns` está activa como gestor de contexto, los estilos de texto y otras propiedades de la fuente pueden cambiarse. Estos cambios estarán contenidos en el contexto. Una vez se cierre, la configuración previa será reestablecida.
164
161
165
162
166
163
## Tutorial 5 - Creando tablas ##
167
164
165
+
Este tutorial explicará cómo crear dos tablas diferentes,
166
+
para demostrar lo que se puede lograr con algunos ajustes simples.
[Archivo de texto con países](https://github.com/py-pdf/fpdf2/raw/master/tutorial/countries.txt)
174
174
175
-
_⚠️ This section has changed a lot and requires a new translation: <https://github.com/py-pdf/fpdf2/issues/267>_
176
-
177
-
English versions:
175
+
El primer ejemplo es alcanzado de la forma más básica posible, alimentando datos a [`FPDF.table()`](https://py-pdf.github.io/fpdf2/Tables.html). El resultado es rudimentario pero muy rápido de obtener.
0 commit comments