Skip to content
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

Upgrade FPDF to version 2 and fix backward incompatibilities #111

Open
reingart opened this issue Mar 25, 2023 · 5 comments
Open

Upgrade FPDF to version 2 and fix backward incompatibilities #111

reingart opened this issue Mar 25, 2023 · 5 comments
Labels
good first issue Good for newcomers

Comments

@reingart
Copy link
Member

To bump fpdf library some changes are needed as new version is backward incompatible

pip unistall fpdf
pip install fpdf2

Errors python pyfepdf.py --prueba

Encodign in UTF-8
Prueba!
/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/fpdf.py:1887: UserWarning: Substituting font arial by core font helvetica
  warnings.warn(
/home/devel/pa/pyfepdf.py:1650: DeprecationWarning: "dest" is deprecated, unused and will soon be removed
  return self.template.render(archivo, dest)
Traceback (most recent call last):
  File "/home/devel/pa/pyfepdf.py", line 2105, in <module>
    main()
  File "/home/devel/pa/pyfepdf.py", line 2098, in main
    fepdf.GenerarPDF(archivo=salida)
  File "/home/devel/pa/pyafipws/utils.py", line 240, in capturar_errores_wrapper
    return func(self, *args, **kwargs)
  File "/home/devel/pa/pyfepdf.py", line 1650, in GenerarPDF
    return self.template.render(archivo, dest)
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/template.py", line 686, in render
    super().render()
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/template.py", line 575, in render
    self.handlers[handler_name](**ele)
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/template.py", line 354, in _text
    pdf.cell(w=width, h=height, txt=text, border=0, align=align, fill=fill)
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/fpdf.py", line 220, in wrapper
    return fn(self, *args, **kwargs)
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/fpdf.py", line 2728, in cell
    align = Align.coerce(align)
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/enums.py", line 142, in coerce
    return super(cls, cls).coerce(value)
  File "/home/devel/pa/.venv/lib/python3.10/site-packages/fpdf/enums.py", line 55, in coerce
    raise ValueError(f"{value} is not a valid {cls.__name__}")
ValueError: I is not a valid Align
```

Proper Unit Test should be written comparing current PDF with the one generated by the new library
@reingart reingart added the good first issue Good for newcomers label Mar 25, 2023
@Lucas-C
Copy link

Lucas-C commented Mar 26, 2023

Hi, fpdf2 maintainer here 😊

Thank you for making this compatibility test and sharing the results.

Regarding this ValueError: I is not a valid Align, I don't understand how this can be a valid value for align...
I don't see it documented anywhere, or even appearing in the code of https://github.com/reingart/pyfpdf.
I think it must fall in the else case there: https://github.com/reingart/pyfpdf/blob/master/fpdf/fpdf.py#L760

If you have an explanation for the meaning of this value of align='I', we could consider adding backward-compatible support for it in fpdf2. But right now it seems more relevant to fix https://github.com/PyAr/pyafipws code to get rid of this strange value of align='I' 😅

@gmischler
Copy link

Late to the party, but anyway...

align="I" is obviously a client-side bug, and was probably meant to read align="J".
On the library side, silently ignoring an invalid parameter value - as the legacy version does - should also be considered a bug.
Fix both bugs, (and any similar ones that may come up), and the transition should proceed rather smoothly.

For your convenience: A List of API differences between PyFPDF and fpdf2

@RohitP2005
Copy link

RohitP2005 commented Dec 11, 2024

hey @Lucas-C if the issue is still open , i would like to work on it, if it is unassigned

@Lucas-C
Copy link

Lucas-C commented Dec 11, 2024

Hi.

I am not a maintainer of https://github.com/PyAr/pyafipws 😅

You should probably ask @reingart

@RohitP2005
Copy link

@Lucas-C thanks for the clarrification. @reingart I would like to work on issue. Is it assigned to someone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants