Tag web

PHPWord

I know, I know. I've been absolutely terrible about updating. My running days have been rough. I'm nursing a knee injury that I'd rather take care of and not have come back. I managed to knock off 12 minutes off my 10K PR though in a race about a month ago! I was very excited about that. Anywho, this post is not about running. It's about something I learned at work. I have been developing an application that spits out a filled Word document. Not only that, I had a template I wanted to use as well. What to do? Enter PHPWord. It's a PHP class that allows you to create brand new Word documents, use a template, add images. All this without having to open Microsoft Word. The zip file from Github has a gazillion examples. The issue I was having was trying to add an image to the template. I ran into this StackOverflow form post. If you add the code they provide to the Template.php, this gives you the ability to replace an image placeholder in the document. They even give you this code bit on how to use it:

Check your variable names….

...and actually read the stinkin' error code while you're at it! If you haven't noticed by now, I am blonde. Yep! Guilty as charged. It also doesn't help that I've always had this bad habit of skimming. Yes. I know about it. No, I'm not great at fixing this issue. I've done it forever.