From 5919ffb16e7e637b5b4cdaa18d758eb82b361647 Mon Sep 17 00:00:00 2001 From: Tomas Rutkauskas Date: Fri, 6 Nov 2026 16:48:29 +0200 Subject: [PATCH] Fix the PDF thumbnail example: convert page 1 straight to JPG pdf -> extract is now the AI data-extraction converter: it returns JSON and has no PageRange, so the example's second step got a JSON file instead of page 1 and failed. One pdf -> jpg call with PageRange=1 now makes the thumbnail, in one conversion instead of two. ScaleImage and ScaleProportions are not pdf -> jpg parameters and the API ignored them, so the 300x300 request came back 300x388 for test.pdf. FitToSize keeps the thumbnail inside 300x300 (231x300). Co-Authored-By: Claude Opus 5.5 --- examples/create_pdf_thumbnail.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/examples/create_pdf_thumbnail.php b/examples/create_pdf_thumbnail.php index 4cd271e..6ae14ef 100644 --- a/examples/create_pdf_thumbnail.php +++ b/examples/create_pdf_thumbnail.php @@ -6,28 +6,19 @@ # set your api secret or token ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET')); -# Example of extracting first page from PDF and then chaining conversion PDF page to JPG. -# https://www.convertapi.com/pdf-to-extract +# Example of converting the first page of a PDF to a JPG thumbnail. # https://www.convertapi.com/pdf-to-jpg $dir = sys_get_temp_dir(); -$pdfResult = ConvertApi::convert( - 'extract', - [ - 'File' => 'files/test.pdf', - 'PageRange' => 1, - ] -); - $jpgResult = ConvertApi::convert( 'jpg', [ - 'File' => $pdfResult->getFile(), - 'ScaleImage' => true, - 'ScaleProportions' => true, + 'File' => 'files/test.pdf', + 'PageRange' => 1, 'ImageHeight' => 300, 'ImageWidth' => 300, + 'FitToSize' => true, ] );