I’m using InvoicePlane v1.5.9 to issue invoices in two different languages. To be able to achieve that, I’ve written this multilanguage PDF template to act as a template selector:
<?php
// If the customer's language is Greek or system default, the invoice will be in Greek.
// Otherwise in English
if ($invoice->client_language == "Greek" || $invoice->client_language == "system") {
// Code that loads the Greek PDF Template
include 'PDF-EL.php';
} else {
// Code that loads the English PDF Template
include 'PDF-EN.php';
}
?>
This is working great, except one thing: I can’t have different PDF footer text for each language.
I’ve tried using PHP code in Settings>Invoices>PDF Footer box, but the coded isn’t parsed.
I’ve thought about adding the footer to each PDF template directly, but’ it seems that whatever I add to the PDF template, it is displayed right after the Terms section and not at the end of the page.
As a side note… I’d prefer not to edit InvoicePlane core files, unless there is no other way.
This is working great, except one thing: I can’t have different PDF footer text for each language.
I am afraid the only possible way would be to leave empty the PDF Footer box and to include the footer at the end of your templates. Alternatively, you could write the text in both languages in the PDF Footer box and display the message in both languages.
I’ve tried using PHP code in Settings>Invoices>PDF Footer box, but the coded isn’t parsed.
It will not work by design: you can only enter HTML code in this box, and the content is passed verbatim (i.e. it is not parsed) to the IP functions that generate the PDF files, thus, PHP will not work here.
I’ve thought about adding the footer to each PDF template directly, but’ it seems that whatever I add to the PDF template, it is displayed right after the Terms section and not at the end of the page.
I guess you mean “right before the Terms” otherwise the sentence doesn’t make sense to me (but I may be wrong).
To display the text at the end of the PDF file you have to include it in the footer section of the template, before of after the line that displays the invoice terms
<footer>
<!-- INSERT YOUR CODE HERE -->
<?php if ($invoice->invoice_terms) : ?>
<div class="notes">
<b><?php _trans('terms'); ?></b><br/>
<?php echo nl2br(htmlsc($invoice->invoice_terms)); ?>
</div>
<?php endif; ?>
<!-- OR INSERT YOUR CODE HERE -->
</footer>
As a side note… I’d prefer not to edit InvoicePlane core files, unless there is no other way.
You should be able to achieve your goal by editing the template files.
Thank you @miquel_cabanas for your answer. The following screenshot explains better what I need to do.
I placed the text This is the footer section of the PDF template according to your code snippet, right inside the PDF template at the footer section. But the result is not what I’d like to have.
Do you see the IBAN section at the bottom of the invoice? This is the HTML Code that I’ve placed in Settings > Invoices > Invoice Template > PDF Footer (box). I need to have different text for each language at that position at the bottom of the invoice.