-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: new and more functional TOC class #1122
Comments
Hi @CayhanBoran! Basically your issue is that You could try using a render function that right-aligns page numbers, instead of using dots, like this: def render_toc_with_right_aligned_page_numbers(pdf, outline):
pdf.set_font("Helvetica", size=16)
for section in outline:
link = pdf.add_link(page=section.page_number)
pdf.cell(text=f'{" " * section.level * 2} {section.name}', link=link, new_x="LEFT")
pdf.cell(text=f"{section.page_number}", link=link, w=pdf.epw, align="R")
pdf.ln() Does this answer solve your issue? 🙂 |
Yes solves partially, I wanted to use Helvetica or Arial with dots, but if that is not the case. I guess I will not use dots in the table of contents. |
The underlying issue is that using dots to align the page number is a very ugly hack, which was cobbled together decades ago, and never fixed. Ideally, someone would submit a PR creating a new and more functional TOC class, which contains adaptable TocEntry instances.
Any takers? |
Just a note: following @gmischler comment, I renamed this issue into |
For reference, a new ToC implementation was implemented by @andersonhc in version 2.8.2: |
Hey everyone,
I am trying to create a table of contents with different font style for landscape format. The aligments of dots in the texts are not aligning. I tried different formats, but the only best option is using the Courier format.
used function for table of contents:
If I make it with Courier and font size 12:
If I make it with Arial and font size 12:
If you could help me and solve this issue of font style in table of contents, I would be really happy.
Thanks!
The text was updated successfully, but these errors were encountered: