What version of FileMaker are you using? (The invoices template design released with each version is different.)
It appears that you've made fairly extensive changes to the original design. We'd need to know more about those changes. The scripts involved, which we cannot see here, are a likely source of the trouble.
Thanks for the response, I'm working with FileMaker 13.
I actually started from scratch and now it's working ok. So I still don't understand what the problem was?
There's no way that I can tell from here as I can't tell what your scripts, etc. do from the info provided.