PDF is being created, but badly formatted