[BUGFIX] creating the pdf should be the last thing to do