From 00955d401369db6de7c0619ae8876bfd27d5ffa4 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. One pdf -> jpg call with pagerange=1 and imageheight=300 now makes the thumbnail (231x300 for test.pdf), in one conversion instead of two. scaleimage and scaleproportions are dropped: they are not pdf -> jpg parameters and the API ignored them. Co-Authored-By: Claude Opus 5.5 --- .../com/convertapi/examples/CreatePdfThumbnail.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java b/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java index 65d3ecf..ab47f3b 100644 --- a/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java +++ b/examples/src/main/java/com/convertapi/examples/CreatePdfThumbnail.java @@ -14,8 +14,7 @@ import static java.lang.System.getenv; /** - * 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 */ public class CreatePdfThumbnail { @@ -26,15 +25,9 @@ public static void main(String[] args) throws IOException, ExecutionException, I System.out.println("Creating PDF thumbnail"); - CompletableFuture pdfFirstPageResult = ConvertApi.convert("pdf", "extract", - new Param("file", Paths.get("files/test.pdf")), - new Param("pagerange", "1") - ); - CompletableFuture thumbnailResult = ConvertApi.convert("pdf", "jpg", - new Param("file", pdfFirstPageResult), - new Param("scaleimage", "true"), - new Param("scaleproportions", "true"), + new Param("file", Paths.get("files/test.pdf")), + new Param("pagerange", "1"), new Param("imageheight", 300) );