Cannot save the converted file as DOCX using PDF to DOCX API PHP

Hi.
I am trying to save the DOCX file that is generated after hitting the PHP PDF to DOCX File. When I try to save it directly it is not getting opened and is throwing an error that probably the file is corrupted or cannot be read. Can you please help me with a solution to save the response in a DOCX file on my system without any errors? file_put_content is saving a DOCX file but the file is not getting opened.
This is the piece of my code.

$wordsApi= new WordsApi(‘xxxxxxx-xxxxxx’,‘xxxxxx-xxxxxx’);
$pdf = $filePath;
$request = new ConvertDocumentRequest(
$pdf, “docx”, NULL, NULL, NULL, NULL
);
$convert=$wordsApi->convertDocument($request);
file_put_contents(public_path(‘documents/’.$docFileName), $convert);

@avluezoid
Please check the sample code to save the resultant document to the local drive. It will help you to accomplish the task.

$request = new Aspose\Words\Model\Requests\ConvertDocumentRequest($file, $format,null);
$result = $wordsApi->ConvertDocument($request);	
copy($result->getPathName(),"PDFtoDOCX.pdf");