Is it still feasible to direct an internal link to a page that has not been created yet, without specifying the page number ? #729
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
Hi! Thank you for reaching out @nsimonovici and welcome to the What you describe is very strange and may be a bug... We only added some extra features to it in We have a set of unit tests regarding Could you please provide some minimal Python code reproducing your issue? |
Beta Was this translation helpful? Give feedback.
-
I don't know if this is a regression or expected behaviour, but I ran into a problem upgrading to fpdf2 with the same error. Pre-building all of the links by calling from fpdf import FPDF
pdf = FPDF()
pdf.set_font("helvetica")
link_to_section1 = pdf.add_link() # *before* add_page
pdf.add_page() # page 1
pdf.cell(text="Section 1", link=link_to_section1)
pdf.add_page() # page 2
pdf.set_link(link_to_section1, page=pdf.page)
pdf.cell(text="Section 1: Bla bla bla") results in:
|
Beta Was this translation helpful? Give feedback.
Hi!
Thank you for reaching out @nsimonovici and welcome to the
fpdf2
community 😊What you describe is very strange and may be a bug...
FPDF.add_link()
in the latest releases should be fully backward compatible with the earlier versions offpdf2
and evenPyFPDF
.We only added some extra features to it in
v2.6.1
.Calling
set_link()
is simply now optional: whereas you previously had to calllink = pdf.add_link()
andpdf.set_link(link, page=2)
, you can now just make a single calllink = pdf.add_link(page=2)
, if you know the target page number upfront.But calling
set_link()
is still valid.We have a set of unit tests regarding
add_link()
that ensure the same features still work as they used to: