What caused this error for me:
- Any echo, print, or var_dump statements before the mPDF instance is used.
- Error messages or warnings being displayed before mPDF starts processing.
Since you are seeing the error chances are you are displaying errors and warnings. Turn that off