PHP Examples

Complete PHP integration examples

Basic Usage

<?php

$api_key = getenv('SPEEDSTEIN_API_KEY');

$data = [
    'html' => '<html><body><h1>Hello PDF!</h1></body></html>',
    'options' => ['format' => 'A4']
];

$ch = curl_init('https://api.speedstein.com/v1/pdf/generate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $api_key,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);
$result = json_decode($response, true);

echo "PDF generated: " . $result['download_url'];
?>