Repository navigation
Examples: use documented converters, read the production catalog, save SplitPDF to temp, hide account secrets - #86
Merged
Conversation
…x300 The example already converts page 1 straight to JPG, but its comment still described the old extract-then-convert chain and linked pdf-to-extract, which is now the AI data-extraction converter. 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 <noreply@anthropic.com>
…les from any folder The examples reached Examples/TestFiles through paths relative to the working directory, three levels up in six places and four in nine. From bin/Debug/net10.0 only the four-level form reached TestFiles, from the project or repository folder neither did, and the backslash paths do not resolve on macOS or Linux. UploadOnceReuseTwice and Workflow climbed four levels from AppContext.BaseDirectory, and SplitPDF read files/sample.pdf from the working directory. Each example's .csproj now copies the sample files it uses to TestFiles/ next to the program, and Program.cs reads them through AppContext.BaseDirectory, so the examples run from dotnet run, Visual Studio and Rider, on any OS. The examples read the API token from the CONVERTAPI_TOKEN environment variable, the name the README quick start (#83) and the C# pages on convertapi.com use, instead of a hard-coded "api_token". Examples/README.md says how to set it and run an example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Process.Start(path) uses UseShellExecute = false on .NET Core and later, so it tries to execute the saved PDF itself and throws Win32Exception on every OS (on macOS: "Permission denied"). The result was already saved and its path printed, so the example now ends there, like the other examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
web -> pdf, pdf -> watermark, pdf -> watermark-overlay and jpg -> zip still convert on production, but the API spec (https://v2.convertapi.com/info/openapi) does not list them, so neither the docs nor the converter pages describe them. The examples now call the documented converters, which take the same parameters: - ConvertUrlToPdf: html -> pdf (Url, FileName). - WatermarkPdf: pdf -> text-watermark (Text, FontSize, VerticalAlignment) and pdf -> pdf-watermark (OverlayFile, Style, Opacity). The result looks the same as with the old converters. - Workflow: file -> zip. The JPGs go in as Files, the converter's parameter. Under the default name File, a single JPG (from a one-page PDF) is rejected with "Files array item count must be greater than 0". - GetConverterInfoDemo: any -> pdf is not in the spec and printed "Converter path '/convert/any/to/pdf' not found in OpenAPI document."; the demo shows file -> pdf instead, which also accepts many formats. The doc comments link the pages of the converters the examples now use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The demo printed the production address and then set ApiBaseUri to staging (https://stag-v2.convertapi.com), so it listed the staging converters. It now reads https://v2.convertapi.com, the address it prints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The example wrote its 19 result files to output/ in the working directory, which is the repository root with dotnet run --project Examples/SplitPDF, and output/ is not in .gitignore. It now saves them in a SplitPDF folder in the temp folder, like the other examples save theirs, and prints where. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
People paste console output into issues and support tickets. The example still prints the account status, name, email and conversion counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the .NET SDK example updates.
No open issues 🎉
What changed in this PR
Updates the .NET SDK examples to use documented converters, production catalog data, and safer output handling without changing the library. The diff also includes the portability and thumbnail fixes from stacked PRs #82 and #85.
Changes:
- Uses documented converter names and explicitly supplies
Filesfor ZIP conversion, including single-file inputs. - Removes the staging catalog override, saves SplitPDF results under the temp folder, and stops printing account credentials.
- Reads tokens from
CONVERTAPI_TOKEN, bundles sample inputs for working-directory independence, and corrects thumbnail sizing and run instructions.
| File | Description |
|---|---|
| Examples/Workflow/Workflow.csproj | Copies the sample PDF into build output. |
| Examples/Workflow/Program.cs | Uses portable inputs and documented ZIP conversion with Files. |
| Examples/WatermarkPdf/WatermarkPdf.csproj | Copies both watermark sample PDFs. |
| Examples/WatermarkPdf/Program.cs | Updates converters and documentation links; removes automatic file launching. |
| Examples/UploadOnceReuseTwice/UploadOnceReuseTwice.csproj | Copies the sample DOCX into build output. |
| Examples/UploadOnceReuseTwice/README.md | Documents environment-token setup and command-line execution. |
| Examples/UploadOnceReuseTwice/Program.cs | Reads the environment token and bundled DOCX. |
| Examples/SplitPDF/Program.cs | Uses a bundled input and saves results under the temp folder. |
| Examples/SplitAndMergePdf/SplitAndMergePdf.csproj | Copies the sample PDF into build output. |
| Examples/SplitAndMergePdf/Program.cs | Reads the environment token and bundled PDF. |
| Examples/RetrieveUserInformation/Program.cs | Reads the environment token and omits credential output. |
| Examples/README.md | Adds setup, execution, and sample-file guidance. |
| Examples/MergeWordDocsToPdf/Program.cs | Uses the environment token and bundled document inputs. |
| Examples/MergeWordDocsToPdf/MergeWordDocsToPdf.csproj | Copies the DOCX and PowerPoint samples. |
| Examples/HandleRetry/Program.cs | Reads the environment token and bundled PDF. |
| Examples/HandleRetry/HandleRetry.csproj | Copies the sample PDF into build output. |
| Examples/GetConverterInfoDemo/Program.cs | Uses the environment token and documented file → pdf lookup. |
| Examples/FromStreamToStream/Program.cs | Reads the token from the environment. |
| Examples/ExceptionHandling/Program.cs | Uses the environment token and bundled invalid-format sample. |
| Examples/ExceptionHandling/ExceptionHandling.csproj | Copies the sample DOCX into build output. |
| Examples/DeleteFiles/Program.cs | Reads the environment token and bundled DOCX. |
| Examples/DeleteFiles/DeleteFiles.csproj | Copies the sample DOCX into build output. |
| Examples/CreatePdfThumbnail/Program.cs | Corrects documentation and uses FitToSize with portable inputs. |
| Examples/CreatePdfThumbnail/CreatePdfThumbnail.csproj | Copies the sample PDF into build output. |
| Examples/ConvertWordToPdfAndPng/Program.cs | Reads the environment token and bundled DOCX. |
| Examples/ConvertWordToPdfAndPng/ConvertWordToPdfAndPng.csproj | Copies the sample DOCX into build output. |
| Examples/ConvertUrlToPdf/Program.cs | Uses documented html → pdf conversion and the environment token. |
| Examples/ConvertRemoteFile/Program.cs | Reads the token from the environment. |
| Examples/ConvertPdfToXlsx/Program.cs | Reads the environment token and bundled PDF. |
| Examples/ConvertPdfToXlsx/ConvertPdfToXlsx.csproj | Copies the sample PDF into build output. |
| Examples/ConvertPdfToPptx/Program.cs | Reads the environment token and bundled PDF. |
| Examples/ConvertPdfToPptx/ConvertPdfToPptx.csproj | Copies the sample PDF into build output. |
| Examples/ConvertPdfToPdfA/Program.cs | Uses the environment token and bundled invoice inputs. |
| Examples/ConvertPdfToPdfA/ConvertPdfToPdfA.csproj | Copies the invoice PDF and XML samples. |
| Examples/ConvertPdfToDocx/Program.cs | Reads the environment token and bundled PDF. |
| Examples/ConvertPdfToDocx/ConvertPdfToDocx.csproj | Copies the sample PDF into build output. |
| Examples/ConverterCatalogDemo/Program.cs | Removes the staging override to use the production catalog. |
Review effort: Balanced
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #85, which is stacked on #82. Please merge #82 and #85 first; until then this pull request also shows their three commits (3d70c44, 0d44e92, e6a4edd). This pull request's own changes are the last four commits: examples-run-as-written...examples-documented-converters
#85 made the examples run as written and listed these problems without fixing them, to stay focused.
Problem
web -> pdf), WatermarkPdf (pdf -> watermark,pdf -> watermark-overlay) and Workflow (jpg -> zip) call converters that still convert on production but are not in the API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09), so neither the docs nor the converter pages describe them. GetConverterInfoDemo asks forany -> pdf, which is not in the spec either, and printedFailed to get converter info for any->pdf: Converter path '/convert/any/to/pdf' not found in OpenAPI document.Base URI: https://v2.convertapi.comand then setConvertApi.ApiBaseUri = "https://stag-v2.convertapi.com".output/in the working directory, which is the repository root withdotnet run --project Examples/SplitPDF, and.gitignoredoes not coveroutput/.SecretandApiKey. People paste console output into issues and support tickets.Change
The examples call the documented converters. Their parameters have the same names, so only the converter names change:
web -> pdfhtml -> pdfUrl,FileNamepdf -> watermarkpdf -> text-watermarkText,FontSize,VerticalAlignmentpdf -> watermark-overlaypdf -> pdf-watermarkOverlayFile,Style,Opacityjpg -> zipfile -> zipFilesany -> pdffile -> pdfThe doc comments link the pages of the new converters: https://www.convertapi.com/html-to-pdf, https://www.convertapi.com/pdf-to-text-watermark and https://www.convertapi.com/pdf-to-pdf-watermark. All three are in the site's sitemap; /web-to-pdf, /pdf-to-watermark and /pdf-to-watermark-overlay are not.
Workflow names the parameter,
new ConvertApiFileParam("Files", firstTask), becausefile -> ziptakesFiles. Under the default nameFile, the SDK sendsfiles[0],files[1], ... only when there are two or more files; the single JPG of a one-page PDF would go asfileand be rejected. One file posted to/convert/file/to/zipunder each name:ConverterCatalogDemo no longer sets
ApiBaseUri, so it reads the production catalog, at the address it prints.SplitPDF saves to a
SplitPDFfolder in the temp folder (Path.GetTempPath()), in the same six subfolders, and prints where.RetrieveUserInformation no longer prints
SecretandApiKey; it still prints the account status, name, email and conversion counts.Only the examples change, not the library, so there is no CHANGELOG entry.
Verification
Run on macOS (arm64) with .NET SDK 10.0.401 against the production API on 2026-11-09, with
CONVERTAPI_TOKENset and nothing edited.$TMPDIRis the local temp folder; account fields are masked as***.dotnet build ConvertApi.sln: 0 errors. Merged into currentmain, the CI steps (dotnet build ConvertApi.sln -c Release -p:ContinuousIntegrationBuild=true, thendotnet test ConvertApi.Tests/ConvertApi.Tests.csproj) give 0 errors and 4 of 4 tests passed. The 3 warnings are the ones Examples: read the token from CONVERTAPI_TOKEN and find the sample files from any folder #85 lists (CS8603 and CS8625 in ConverterCatalogDemo, CS0618 in GetConverterInfoDemo), in lines this pull request does not change.dotnet run --project Examples/<Name> < /dev/nullfrom the repository root and exited with code 0.html -> pdfsaved$TMPDIR/web-example.pdf, but Wikimedia answered with its "Too many requests" page instead of the article, as it also did for the oldweb -> pdf(see "Found, not changed"). With another page, https://www.w3.org/,html -> pdfreturned the whole web page, 2 pages with its images and styles.watermarkandwatermark-overlayconverters with the same parameters, apart from the time in the text.test.zipholds the six page JPGs,test.jpgandtest-2.jpgtotest-6.jpg.lsof) went to 159.8.243.100, an address ofv2.convertapi.com. Before this change it connected only to 52.117.108.126,stag-v2.convertapi.com, while it printed the production address. Staging and production serve the same spec today (328 converters each), so the printed output does not show the difference.$TMPDIR/SplitPDF. Nooutput/folder in the repository, andgit statusis clean after the run.SecretorApiKeyline.GetConverterInfoDemo and ConverterCatalogDemo output
Found, not changed
html -> pdfon all 12 tries over 35 minutes, and the oldweb -> pdfon 3 of 4 tries (the first rendered the 3-page article). From a developer machine the page answers 200 to the same HeadlessChrome user agent, so it looks like rate limiting of ConvertAPI's servers. The same URL is in the Go, Java, Node, PHP, Python and Ruby examples and in code samples on convertapi.com, so a different demo page, or a change in the converter, belongs in its own change.🤖 Generated with Claude Code