Thank you garrettroyce,
At last I do it with pg_dump through the PHP function passthru() to get the file. The problem was setting the password. You can force pg_dump to prompt for a password by the -W option. But, what if you want to pass the password to the command to avoid the need to prompt?
I've found you can set an enviroment variable called "PGPASSWORD" (setenv() in PHP) which will be used by pg_dump. I don't know why that is not documented on postgresql.org but it works.
Regards,
Javier