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
Currently I am trying to create a boilerplate template for some recurring reports, featuring amongst other a toc with links to each corresponding section.
For laying out the toc I'm facilitating the fpdf2 table class. According to the documentation found on the project home page, adding a link to a table row should be rather straight forward
row.cell(..., link=...)
Unfortunately this renders an error upon execution, stating the 'link' is an unexpected keyword.
Turning to the documentation for help, having a look at the tutorial, I tried to code shown there
pdf.set_draw_color(50) # very dark grey
pdf.set_line_width(.5)
with pdf.table(width=150, col_widths=(30, 30, 10, 30),
text_align=("CENTER", "CENTER", "RIGHT", "LEFT"),
line_height=2.5 * pdf.font_size,
headings_style=headings_style,
cell_fill_color=greyscale, cell_fill_mode="ROWS",
borders_layout="MINIMAL") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum, link="https://pyfpdf.github.io/fpdf2/Tables.html")
pdf.output('table.pdf')`
When running this sequence the following output is getting generated
`Python 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 8.14.0
Python 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0] on linux
import os
os.environ['KEYRING_CRYPTFILE_PASSWORD'] = 'usrpwd'
os.environ['USRENV'] = 'usrenv'
runfile('/home/user/projects/pdf/test.py', wdir='/home/user/projects/pdf')
Traceback (most recent call last):
File "/usr/local/miniconda3/envs/user/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 4, in
runfile('/home/user/projects/pdf/test.py', wdir='/home/user/projects/pdf')
File "/opt/pycharm-community/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/pycharm-community/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/user/projects/pdf/test.py", line 34, in
row.cell(datum, link="https://pyfpdf.github.io/fpdf2/Tables.html")
TypeError: Row.cell() got an unexpected keyword argument 'link'`
I am using FPDF2 v2.7.4.
Having the possibility of linking adding links to table rows would be kind of an nice to important thing to have working.
Cheers!
Sil
The text was updated successfully, but these errors were encountered:
Currently I am trying to create a boilerplate template for some recurring reports, featuring amongst other a toc with links to each corresponding section.
Unfortunately this renders an error upon execution, stating the 'link' is an unexpected keyword.
This is because our documention is slightly in advance compared to the latest release... Sorry about this.
The feature you want to use has been added 4 days ago: #825
It is not released yet but you can test it before the next release using this command: pip install git+https://github.com/PyFPDF/fpdf2.git@master
Hi,
First of all, you guys rock! Amazing package!
Currently I am trying to create a boilerplate template for some recurring reports, featuring amongst other a toc with links to each corresponding section.
For laying out the toc I'm facilitating the fpdf2 table class. According to the documentation found on the project home page, adding a link to a table row should be rather straight forward
row.cell(..., link=...)
Unfortunately this renders an error upon execution, stating the 'link' is an unexpected keyword.
Turning to the documentation for help, having a look at the tutorial, I tried to code shown there
`# https://pyfpdf.github.io/fpdf2/Tables.html
from fpdf import FPDF
from fpdf.fonts import FontFace
TABLE_DATA = (
("First name", "Last name", "Age", "City"),
("Jules", "Smith", "34", "San Juan"),
("Mary", "Ramos", "45", "Orlando"),
("Carlson", "Banks", "19", "Los Angeles"),
("Lucas", "Cimon", "31", "Saint-Mahturin-sur-Loire"),
)
pdf = FPDF()
pdf.add_page()
pdf.set_font("Times", size=10)
blue = (0, 0, 255)
lightblue = (173, 216, 230)
grey = (128, 128, 128)
greyscale = 200
headings_style = FontFace(emphasis="ITALICS", color=blue, fill_color=grey)
pdf.set_draw_color(50) # very dark grey
pdf.set_line_width(.5)
with pdf.table(width=150, col_widths=(30, 30, 10, 30),
text_align=("CENTER", "CENTER", "RIGHT", "LEFT"),
line_height=2.5 * pdf.font_size,
headings_style=headings_style,
cell_fill_color=greyscale, cell_fill_mode="ROWS",
borders_layout="MINIMAL") as table:
for data_row in TABLE_DATA:
row = table.row()
for datum in data_row:
row.cell(datum, link="https://pyfpdf.github.io/fpdf2/Tables.html")
pdf.output('table.pdf')`
When running this sequence the following output is getting generated
`Python 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 8.14.0
Python 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0] on linux
import os
os.environ['KEYRING_CRYPTFILE_PASSWORD'] = 'usrpwd'
os.environ['USRENV'] = 'usrenv'
runfile('/home/user/projects/pdf/test.py', wdir='/home/user/projects/pdf')
Traceback (most recent call last):
File "/usr/local/miniconda3/envs/user/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 4, in
runfile('/home/user/projects/pdf/test.py', wdir='/home/user/projects/pdf')
File "/opt/pycharm-community/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/pycharm-community/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/user/projects/pdf/test.py", line 34, in
row.cell(datum, link="https://pyfpdf.github.io/fpdf2/Tables.html")
TypeError: Row.cell() got an unexpected keyword argument 'link'`
I am using FPDF2 v2.7.4.
Having the possibility of linking adding links to table rows would be kind of an nice to important thing to have working.
Cheers!
Sil
The text was updated successfully, but these errors were encountered: