This way requires a bit of linux software

Debian / Ubuntu
apt-get install ps2pdf
apt-get install pdf2ps

And then to the magic – lets say that your pdf is located at /home/mypdf.pdf

<?php
shell_exec(“pdf2ps /home/mypdf.pdf /home/mypdf.ps”);
unlink(“/home/mypdf.pdf”);
shell_exec(“ps2pdf /home/mypdf.ps /home/mypdf.pdf”);
unlink(“/home/mypdf.ps”);
?>