We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

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

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
file_put_contents(public_path(‘documents/’.$docFileName), $convert);

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);