From 305033cf4f9500e503f7b2592eff97c7f24b5edb 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.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/examples/create_pdf_thumbnail.py b/examples/create_pdf_thumbnail.py index 43a7956..02b2ecb 100644 --- a/examples/create_pdf_thumbnail.py +++ b/examples/create_pdf_thumbnail.py @@ -4,26 +4,17 @@ convertapi.api_credentials = os.environ['API_TOKEN'] # your api token -# 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 -pdf_result = convertapi.convert( - 'extract', - { - 'File': 'files/test.pdf', - 'PageRange': 1, - } -) - jpg_result = convertapi.convert( 'jpg', { - 'File': pdf_result, - 'ScaleImage': True, - 'ScaleProportions': True, + 'File': 'files/test.pdf', + 'PageRange': 1, 'ImageHeight': 300, 'ImageWidth': 300, + 'FitToSize': True, } )