Free Support Forum -

Convert HTML to PDF in PHP using Aspose.PDF REST API issue


I am having same issue, using php to convert html to PDF

example code

SaasposeApp::$OutPutLocation =SERVER_FILE_PATH.‘media/candidate/pdf/’;

$mainDocumentFile = SERVER_FILE_PATH.’/lib/pdf_converter/test.html’;
//create document object
$pdfDocument = new Document("");
//create PDF from HTML
$result = $pdfDocument->CreateFromHtml($report, $mainDocumentFile);

if($result == “”)
echo “Pdf file has been created successfully”;
catch (Exception $e) {
throw new Exception($e->getMessage());

could you please help to solve this issue ?

Hi Simon,

We are sorry for the inconvenience caused. I am afraid I am unable to notice any cloud service issue while using Aspose for Cloud default storage. We will appreciate if you please share the exact error message and also confirm which storage option you are using. It will help us to investigate the issue.

Best Regards,

Hi Simon,

In addition to above reply. Please also share your sample HTML file for testing.

Best Regards,


As an update, please check HTML to PDF documentation for updated GetHtmlInStorageToPdf API method details. The latest API version of Aspose.PDF Cloud uses JSON Web Token(JWT) for a request authorization and provides Storage API methods for cloud storage operations. Kindly find the sample PHP code for HTML to PDF conversion and check Aspose.PDF Cloud SDK for PHP as well.

        $name = "";
        $html_file_name = "HtmlWithImage.html";
        $height = 650;
        $width = 250;
        $src_path = $tempFolder . '/' . $name;

        $response = $pdfApi->getHtmlInStorageToPdf($src_path, $html_file_name, $height, $width);