You code looks correct to me. I would only suggest to use a full path to the destination directory on your server, eg
$out_file = fopen("/full/path/to/document.pdf", "wb");
fopen() creates a new file on your server,
convertURI() writes PDF to that file, and
fclose() closes the file.