From 3d0eface8e2d2c162e8d8998b1725e7769b2652a 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.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/create_pdf_thumbnail.rb b/examples/create_pdf_thumbnail.rb index 7a08683..ede3c3e 100644 --- a/examples/create_pdf_thumbnail.rb +++ b/examples/create_pdf_thumbnail.rb @@ -5,23 +5,16 @@ config.api_credentials = ENV['API_TOKEN'] # your api token end -# 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} + ImageWidth: 300, + FitToSize: true} ) saved_files = jpg_result.save_files(Dir.tmpdir)