Skip to content

Examples: use the converters the API spec documents - #58

Merged
tomasr78 merged 1 commit into
mainfrom
examples-documented-converters
Nov 9, 2026
Merged

tomasr78 merged 1 commit into
mainfrom
examples-documented-converters

Conversation

@tomasr78

@tomasr78 tomasr78 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Two examples call converters that the production API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09) does not list. Both still convert today, but developers copy these examples and the how-to guides on convertapi.com reuse them, so they should call documented converters. This is the Java part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.

Example Before After
ConvertWebToPdf.java web -> pdf, comment links /web-to-pdf html -> pdf (parameters), same url and filename; comment links https://www.convertapi.com/html-to-pdf
ConversionChaining.java jpg -> zip file -> zip (parameters), same files parameter

https://www.convertapi.com/web-to-pdf is not in the site's sitemap; https://www.convertapi.com/html-to-pdf is. The other examples already call documented converters; the pdf -> extract step of CreatePdfThumbnail goes away with #56.

Verified against production (2026-11-09)

OpenJDK 27.0.1 with convertapi 2.13.1 (the version examples/pom.xml uses): ./mvnw -f examples/pom.xml compile passes. Each example ran from a folder holding files/test.docx, once on main (f74854f) and once on this branch, with the token in API_TOKEN (<tmp> is java.io.tmpdir).

ConversionChaining, same output before and after:

Converting PDF to JPG and compressing result files with ZIP
ConvertApi.convert is not blocking method, proceeding to ZIP conversion
Saving result file (blocking operation)
DOCX -> JPG conversion cost: 1
DOCX -> JPG conversion result file count: 2
JPG -> ZIP conversion cost: 1
ZIP file saved to: <tmp>/test.zip

Both runs saved a 711,617-byte test.zip with test.jpg and test-2.jpg; the JPGs are byte-identical before and after.

ConvertWebToPdf, same output before and after:

Converting WEB to PDF
PDF file saved to: <tmp>/web-example.pdf

The PDF text: on main and in both runs on this branch, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words), the same page the old web -> pdf got. This does not depend on the converter: in the same hour the same html -> pdf call rendered the article (3 pages, 1,925 words) from the Go, Python, PHP and Ruby examples. The demo URL is being looked at separately.

Seen, not changed: ConversionChaining's comment and first message say it converts a PDF, but it converts files/test.docx.

Same change in the other SDKs

🤖 Generated with Claude Code

The production API spec (https://v2.convertapi.com/info/openapi) has no
web -> pdf and no jpg -> zip converter. ConvertWebToPdf now converts the
URL with html -> pdf (same url and filename parameters) and links the
html-to-pdf page. ConversionChaining zips the JPG results with file -> zip
(same files parameter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the two example converter updates.

No open issues 🎉

What changed in this PR

Updates two Java examples to use documented ConvertAPI converters without changing their parameters or the library implementation.

Changes:

  • Switches web-page conversion from web → pdf to html → pdf and updates the documentation link.
  • Switches the ZIP step in the conversion chain from jpg → zip to file → zip.
File Description
examples/​src/​main/​java/​com/​convertapi/​examples/​ConvertWebToPdf.java Uses html → pdf and links to its documentation.
examples/​src/​main/​java/​com/​convertapi/​examples/​ConversionChaining.java Uses file → zip to archive the generated JPG files.

Review effort: Balanced

@tomasr78
tomasr78 merged commit 2cdfce7 into main Nov 9, 2026
5 checks passed
@tomasr78
tomasr78 deleted the examples-documented-converters branch November 9, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants