Replies: 3 comments
-
Hi @bux-derek and thank you for reaching out 🙂 First of, as stated in our documentation, Also, regarding Jinja templating, have you checked our related documentation page for a some usage example ? -> https://py-pdf.github.io/fpdf2/TemplatingWithJinja.html Apart from that, your |
Beta Was this translation helpful? Give feedback.
-
If you want to avoid calling def cell(self, *args, **kwargs):
text_value = kwargs.pop("text", None)
if text_value:
kwargs["text"] = text_value.format(**self.personal_data_dict)
return super().cell(*args, **kwargs)
def multi_cell(self, *args, **kwargs):
text_value = kwargs.pop("text", None)
if text_value:
kwargs["text"] = text_value.format(**self.personal_data_dict)
return super().multi_cell(*args, **kwargs) |
Beta Was this translation helpful? Give feedback.
-
@bux-derek , have you looked at fpdf2s You can prepare different CSV files for different languages, and prepopulate the static text strings in those. You need to figure out which template type best suits your needs. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to determine if I can use FPDF2 for my use case where we need to generate PDF reports with a recurring structure.
Currently we use HTML templates that we convert to PDF using
pdfkit
. We have different HTML templates that we maintain for different languages, which need to be personalised with some data. The process looks like this:I was wondering if we could use FPDF2 to simplify this process. I thought I could create a report builder class (which has FPDF2 as a subclass) that has pre-defined methods that we can use as building blocks to build up reports, and skip the HTML generation completely. I've managed to do create a POC, but the problem I'm facing now is that the personal data needs to be fed into each FPDF method.
Example:
which can be called then as:
Ideally I render the placeholders text after defining the
pdf
object (e.g. by calling arender
method or something, so that i can use it as a template. Is something like this possible, or do you have ideas how to use the FPDF2 class as a template? I looked at theTemplates
class as well, but this is not really what i'm looking for.I'm open for any other direction that could lead to a similar result as well.
Beta Was this translation helpful? Give feedback.
All reactions