PyFPDF内部链接 [英] PyFPDF internal link
本文介绍了PyFPDF内部链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
应如何进行内部链接?我尝试从第1页链接到第2页.没问题.但是从第2页到第2页不起作用.怎么了.
How should internal linking be done? I try to link from page 1 to page 2. That works ok. But from page to page 2 doesn't work. What is wrong.
from fpdf inport FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
to_page_2 = pdf.add_link()
pdf.cell(40, 10, 'Page 1', border=1, ln=0, align='', fill=False, link=to_page_2)
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.set_link(to_page_2)
pdf.cell(40, 10, 'Page 2', border=1, ln=0, align='', fill=False)
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
to_page_2 = pdf.add_link()
pdf.cell(40, 10, 'Page 3', border=1, ln=0, align='', fill=False, link=to_page_2)
pdf.output('pdf_link.pdf', 'F')
推荐答案
您尚未设置第二个链接的目标. set_link
定义页面并链接指向的位置.
You have not set the destination of second link. set_link
defines the page and position a link points to.
在链接第3页的单元格之前添加此行.
Add this line before you link the cell on page 3.
pdf.set_link(to_page_2, page=2)
如果您需要更多有关参数的信息,可以传递给 set_link
,查看
In case you need more info on parameters you can pass to set_link
check out the the documentation.
这篇关于PyFPDF内部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文