linuxpyfpdf

Can't add custom font to python with fpdf on linux


I developed a software on my windows machine with fpdf2 for python. It worked perfectly, but now I have to install this program on a Red Hat Linux server and when I try to add custom font to pdf it throws an error: cannot instantiate 'WindowsPath' on your system

the code:

pdf = FPDF()
FONT_REGULAR = os.path.join(os.path.dirname(__file__), "fonts", "arial.ttf")
pdf.add_font("Regular", "", FONT_REGULAR, uni=True)

At this line it throws an error:

<NotImplementedError> "cannot instantiate 'WindowsPath' on your system"

Is there a workaround to this?

fpdf2 version: 2.4.5


Solution

  • Upgraded to the latest version 2.5.1 and it works with linux also.