����
������������������������������������
$pdfFilename
";
// === Convert API Call ===
$url = 'https://v2.convertapi.com/convert/pdf/to/jpg?Secret=' . $convertApiSecret;
$postFields = ['File' => new CURLFile($uploadedPath)];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$result = json_decode($response, true);
$htmlImages = '';
if (isset($result['Files'])) {
foreach ($result['Files'] as $index => $file) {
$fileName = 'page' . ($index + 1) . '.jpg';
$localImagePath = $outputDir . $fileName;
$imageUrl = $outputUrl . $fileName;
if (!empty($file['FileData'])) {
$imageData = base64_decode($file['FileData']);
if ($imageData !== false && file_put_contents($localImagePath, $imageData)) {
echo "✅ Saved image: $fileName
";
$htmlImages .= '
'
. ''
. '
$clientpointResponse"; } } else { echo "❌ No images returned by ConvertAPI.
$response"; } } else { echo "❌ Failed to move uploaded file.