This sample code demonstrates how to convert HTML to PDF in PHP using ByteScout Cloud API (low level).

Check other articles to learn how to convert HTML to PDF in Java, JavaScript and jQuery using Cloud API.

POST endoint:

Code Sample:

require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: api_key
Bytescout\Client\API\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Bytescout\Client\API\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$api_instance = new Swagger\Client\Api\DefaultApi();
$text = ; // Text | HTML data to convert to PDF.
$name = name_example; // String | File name for the generated result.

try {
    $result = $api_instance->pdfConvertFromHtmlPost($text, $name);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->pdfConvertFromHtmlPost: ', $e->getMessage(), PHP_EOL;