Convert Microsoft Word document to PDF in PHP using Aspose.Words REST API

Hi,



I am using the Aspose Cloud platform to convert .docx documents to .pdf via the PHP SDK. However suddenly as of last week some conversions lead to incomplete pdf files. Doing the conversion again with the exact same request often leads to a correct file.



I’ve done a quick test with 20 conversions with the exact same request and 4 failed (resulting in a corrupt pdf file) and 16 succeeded. I’m not receiving any error whatsoever and my history page is only showing successes.



After opening the pdf files and comparing the corrupt ones with the correct one I noticed that the corrupt files are cut-off at a random place (different for each corrupt pdf file).



Do you have any idea what might be the cause if this issue? Changing timeout settings to prevent a timeout on my side to occur do not solve the issue.



Thank you in advance for your response.



Kind regards,



Robin

Hi Robin,

The issue is fixed. Please check my last mail for a detailed reply.

Best Regards,

@robinem

I would like to update you that since Aspose.Words Cloud 19.4, we have introduced API Version 4.0 and it has some breaking changes. Along with many other changes, now we use JSON Web Token(JWT) for API request authentication instead of OAuth2 and URL signing. Please check the blog post for details and also check the updated Aspose.Words Cloud SDK for PHP.

$wordsApi = new Aspose\Words\WordsApi($ClientID,$ClientSecret);
	
$format = "pdf";
$file = ("C:/Temp/02_pages.docx");
    
$request = new Aspose\Words\Model\Requests\ConvertDocumentRequest($file, $format,null);
$result = $wordsApi->ConvertDocument($request);	
copy($result->getPathName(),"02_pages.pdf");
1 Like