to DannyWoo:
If it opens twice, there must be some error (typo) in the code you have pasted to the VM file.
The invoice is a downloadable PDF file, it should never open within a template. Browser should either offer the file for direct download or open it in a clean window using PDF viewer. That is the default functionality.
It may however be partially dependent on your browser/system settings and also server settings.
To force opening in a new window, the classic html attribute targer="_blank" can be used.
If you need further help resolving the problem, you can also book our paid support.