Adding PHP to PDF Templates

Hello everyone,

I’m interested in trying to insert some PHP Code into a PDF Template for my Quotes. Basically my goal is to take the date that is fed to the quote and change it from MM/DD/YYYY to Month Day, Year (02/01/2014 to February 1, 2014). I know how to do this with PHP code, but the WYSIWYG editor and hmtl editor prevent me from including PHP code in the template. Is there a workaround in the editor or another method you can suggest?


I did not look into this too much further as far as entering PHP into the code. I’m sure it can be done, but it is low on my priority list. Instead, I changed the inserted Date format. This can be done in generatePdf.php in modules/AOS_PDF_Templates/ . Since this is not a custom directory, I doubt that it is upgrade safe.

I changed the following line to match my desired format:
// $text = preg_replace(’/{DATE\s+(.?)}/e’,“date(’\1’)”,$text );
$text = preg_replace(’/{DATE\s+(.
?)}/e’,“date(‘F d, Y’)”,$text );

what is the date format on your system? is it the same as what the PDF is displaying?

did you try and add AOS_PDF_Templates/generate.PDf.php under custom/modules/AOS_PDF_Templates to see if it overrides? This would make it upgrade safe.

My system saves the dates as 02/19/2014. I prefer this format for my records and ease of searching. However, for my quotes I would prefer to not use that format.

I have not tried what you suggested but will do so.

Has anyone found a real solution to this problem? i also want to include PHP on the PDF templates

I still have not looked into this further; however, my plan of attack was to find where the PHP tags are being stripped out of the string and add in some functionality to leave in a certain grouping of characters that would mark it as PHP I wanted to keep. I thought this was inherent to some WYSIWYG editors, but maybe not. It may also be that the PHP tags are being stripped out outside of the editor…