Free Support Forum - aspose.cloud

DOCX to PDF conversion in PHP with Aspose.Words REST API throwing 500 Internal Server Error

Here is the code, I create a document using TemplateProcessor phpWord extensions.
$processor= new TemplateProcessor($document->getPath());
$regexps=$this->repository->getRegExp($document->id);
if($regexps) {
foreach ($regexps as $regexp) {
$processor->setValue(
$regexp->regKey,
$this->documentSave[$regexp->regKey]
);
}
}
$fileName=DownloadDocuments::saveAsPath().’/’.$this->number;
$processor->saveAs($fileName.’.docx’);
$config= new Configuration();
$config->setAppKey(Yii::$app->params[‘asposeKey’])->setAppSid(Yii::$app->params[‘asposeSid’]);
$words=new WordsApi(null,$config);
$saveOptions = new SaveOptionsData([“save_format” => “pdf”, “file_name” => $fileName.’.pdf’]);
$request = new PostDocumentSaveAsRequest($fileName.’.docx’,$saveOptions);

getting the specified error

[500] Server error: POST https://api.aspose.com//v1/words/%2Fvar%2Fwww%2Ftiger.lc%2Fbackend%2Fruler%2Ffiles%2Fdoc%2F38-3-%D0%97.docx/saveAs resulted in a 500 Internal Server Error response:



Runtime Error
<meta name=“viewport” content="width= (truncated…)

@Sergalas

Thank you for contacting Aspose Support.

Please use Aspose.Words Cloud SDK for PHP to call Aspose.Words REST APIs. You will not face any such issue. You may download the words-sdk-php PHP package from Packagist Distribution.

so I use it and actually here’s the code from the site GitHub


$config= new Configuration();
$config->setAppKey(‘asposeKey’)->;setAppSid(‘asposeSid’);
$words=new WordsApi(null,$config);


$saveOptions = new SaveOptionsData([“save_format” => “pdf”, “file_name” =>; $fileName.’.pdf’]);
$request = new PostDocumentSaveAsRequest($fileName.’.docx’,$saveOptions);

@Sergalas

Please share the input file, we will try to reproduce the issue on our end.