Giter Club home page Giter Club logo

Comments (10)

Lucas-C avatar Lucas-C commented on July 18, 2024

Hi and welcome @demiurgepy 🙂

First and foremost, I'd like to express my immense gratitude for the effort put into developing the FPDF library. It's an incredible tool that has been immensely helpful.

Thank you! It makes me happy to know that this library helped you 😊

However, the links in the table cells are not becoming clickable. [...] Here is the snippet of my code:

You did not provide a code snippet that I can easily test 😢
Please provide a minimal reproducible example, that does not require to guess what is your surrounding code and the data you are using: https://stackoverflow.com/help/minimal-reproducible-example

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

I was able to craft a minimal script reproducing your issue, and this is indeed a bug:

#!/usr/bin/env python3
from fpdf import FPDF

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", "Angers"),
)

pdf = FPDF()
pdf.set_font("helvetica", size=8)
pdf.add_page()
with pdf.table() as table:
    for data_row in TABLE_DATA:
        row = table.row()
        for item in data_row:
            row.cell(text=item, link="https://py-pdf.github.io/fpdf2/")
pdf.output("issue_1031.pdf")

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

This was a regression in fpdf2 release 2.7.6, brought by this PR: #797

I'm creating a PR to fix this now.

Thank you for the report @demiurgepy!

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

@allcontributors please add @demiurgepy for bug

from fpdf2.

allcontributors avatar allcontributors commented on July 18, 2024

@Lucas-C

I've put up a pull request to add @demiurgepy! 🎉

from fpdf2.

demiurgepy avatar demiurgepy commented on July 18, 2024

Sorry for not getting that minimal code over to you in time. Thanks a bunch for your quick response though – you guys are amazing!
It's really cool to see such active and helpful support in the community 🤜🤛

from fpdf2.

demiurgepy avatar demiurgepy commented on July 18, 2024

Hi again FPDF Team,

I'm back with an update and further inquiry about the table hyperlink issue I mentioned earlier. This time, I've noticed that when I place a hyperlink in the third column of a table, it strangely extends to the first column as well. This is happening despite my attempts to limit the hyperlink to just the third column.

A minimal script:

from fpdf import FPDF

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=16)
with pdf.table() as table:
    for i, data_row in enumerate(TABLE_DATA):
        row = table.row()
        for j, datum in enumerate(data_row):
            if j == 2 and i > 0:
                row.cell(text=datum, link='https://py-pdf.github.io/fpdf2/')
            else:
                row.cell(datum)
pdf.output('table.pdf')

In this script, the hyperlink is intended only for the "Age" column, but it also activates in the "First name" column. I'm hoping to get some insight or guidance on how to address this issue.

Thanks again for your time and assistance.

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

Hi @demiurgepy

In this script, the hyperlink is intended only for the "Age" column, but it also activates in the "First name" column. I'm hoping to get some insight or guidance on how to address this issue.

I tried your code, and I do not reproduce the problem you are describing, sorry!
It correctly produces a PDF with an hyperlink set only on the numeric values of the 3rd column.

Are you using the latest version of fpdf2 from the master branch?
You can install it this way:

pip install git+https://github.com/py-pdf/fpdf2.git@master

from fpdf2.

demiurgepy avatar demiurgepy commented on July 18, 2024

Thanks Lucas for your prompt response and for taking the time to test the code. I appreciate your efforts to help diagnose the issue.

After receiving your message, I made sure to install the latest version of fpdf2 from the master branch as you suggested. However, I'm still encountering the same issue where a portion of the first column becomes clickable, despite the hyperlink being intended only for the third column. This behavior persists in the generated PDF, with the first few letters in the first column responding as part of the hyperlink.

Interestingly, a few other developers have also tested this on their systems and have reported experiencing the same issue. It seems to be a consistent behavior across different environments. This is a visual example, to give you a clearer idea:
image

Could there be a specific environment or PDF viewer factor at play here? Or might there be a subtle aspect of the library's behavior that we're overlooking?

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

Could there be a specific environment or PDF viewer factor at play here? Or might there be a subtle aspect of the library's behavior that we're overlooking?

No, you were right, there was still a bug related to this in fpdf2 😅
I fixed that in #1061

Sadly, it was not included as part of today's release: https://github.com/py-pdf/fpdf2/releases/tag/2.7.7
But if you install fpdf2 from this repo master branch, you should be able to test if that solves your problem.

from fpdf2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.