Skip to content

Examples: projects for the README's C# tasks and for OCR - #95

Merged
tomasr78 merged 1 commit into
mainfrom
examples-task-projects
Nov 11, 2026
Merged

tomasr78 merged 1 commit into
mainfrom
examples-task-projects

Conversation

@tomasr78

Copy link
Copy Markdown
Contributor

What this adds

Seven example projects. The first six are the README's "... in C#" tasks that had no example of their own; OcrPdf goes with the OCR section that #94 added.

Project What it shows Sample
ConvertDocxToPdf Word to PDF test.docx
ConvertHtmlToPdf an HTML file, and an HTML string such as an invoice, to PDF files (a web page by URL stays in ConvertUrlToPdf) test.html
ConvertExcelToPdf Excel to PDF test.xlsx
ExtractTextFromPdf the text of a PDF into a string test.pdf
CompressPdf compression with Preset=web, printing the size before and after test.pdf
ConvertHtmlToDocx HTML to an editable Word document test.html
OcrPdf a scanned PDF made searchable scanned.pdf (new)

They follow the existing examples and Examples/README.md: a .NET 10 console project that references the library source, reads the token from CONVERTAPI_TOKEN, finds its sample through AppContext.BaseDirectory, saves the result in the temp folder, catches ConvertApiException and prints Status Code: and Response:, and waits for Enter.

  • Each has at most 3 comment lines at the top.
  • Each is in ConvertApi.sln under the Examples folder, so build compiles it and the Examples workflow runs it. The 49 solution lines were added by hand: dotnet sln add would also have rewritten every existing project with x64 and x86 platforms.
  • Each is linked from the Tasks table, from its README section ("Example project: ...") and from the More examples list, which keeps its heading and its order.
  • Examples/TestFiles/scanned.pdf is a made-up letter (fictional companies, an example.com address) rendered to a 150 dpi grayscale JPEG and wrapped in a one-page A4 PDF, with no text layer and no document metadata: 113 KB. The default OCR settings read all of it.
  • No existing example is renamed or removed.

How it was checked

  • Release build of ConvertApi.sln: 0 errors. The only warnings are the 3 that ConverterCatalogDemo and GetConverterInfoDemo already had.
  • .github/ci/check_csharp.py examples with .github/ci/ci-host.targets, as the Examples workflow runs it, but against the staging API (CONVERTAPI_BASE_URI=https://stag-v2.convertapi.com): 7 of 7 passed, and CiHost deleted every uploaded and result file.
Example Result on staging
CompressPdf compressed.pdf, 246,542 bytes: 23% of test.pdf's 1,086,060
ConvertDocxToPdf word-to-pdf.pdf, 146,734 bytes
ConvertExcelToPdf excel-to-pdf.pdf, 43,891 bytes
ConvertHtmlToDocx html-to-word.docx, 13,241 bytes
ConvertHtmlToPdf html-file.pdf, 21,994 bytes, and html-string.pdf, 12,791 bytes
ExtractTextFromPdf printed the 2,485 characters of text
OcrPdf searchable.pdf, 139,419 bytes, with the letter's text as its text layer

In the Examples workflow, which runs against the production API, these add 8 conversions per job (ConvertHtmlToPdf converts twice).

Not changed: the library, the existing examples, build.yml, the CI files, CHANGELOG.md and RELEASING.md.

🤖 Generated with Claude Code

Adds ConvertDocxToPdf, ConvertHtmlToPdf (an HTML file and an HTML string),
ConvertExcelToPdf, ExtractTextFromPdf, CompressPdf (prints the size before
and after) and ConvertHtmlToDocx, the "... in C#" tasks of the README that had
no example of their own, and OcrPdf with a made-up scanned letter in
Examples/TestFiles/scanned.pdf. Each is in ConvertApi.sln, so CI builds and
runs it, and is linked from the Tasks table, its README section and the
More examples list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 10:57

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

There are no active review issues blocking approval of the new examples and README links.

No open issues 🎉

What changed in this PR

Adds seven runnable examples for the README’s C# conversion tasks, including the OCR documentation introduced in #94. The examples use the library source and follow the existing console-project structure.

Changes:

  • Demonstrates Word, Excel and HTML conversions, PDF text extraction, compression and OCR.
  • Adds .NET 10 projects with sample-file copying and solution registration.
  • Links the examples from the README’s task table, relevant sections and examples list.
File Description
README.md Links all seven new examples.
Examples/​OcrPdf/​Program.cs Demonstrates making a scanned PDF searchable.
Examples/​OcrPdf/​OcrPdf.csproj Configures the OCR project and scan sample.
Examples/​ExtractTextFromPdf/​Program.cs Reads extracted PDF text into a string.
Examples/​ExtractTextFromPdf/​ExtractTextFromPdf.csproj Configures the text-extraction project and sample.
Examples/​ConvertHtmlToPdf/​Program.cs Converts an HTML file and string to PDFs.
Examples/​ConvertHtmlToPdf/​ConvertHtmlToPdf.csproj Configures the HTML-to-PDF project and sample.
Examples/​ConvertHtmlToDocx/​Program.cs Converts HTML to an editable Word document.
Examples/​ConvertHtmlToDocx/​ConvertHtmlToDocx.csproj Configures the HTML-to-Word project and sample.
Examples/​ConvertExcelToPdf/​Program.cs Demonstrates Excel-to-PDF conversion.
Examples/​ConvertExcelToPdf/​ConvertExcelToPdf.csproj Configures the Excel project and workbook sample.
Examples/​ConvertDocxToPdf/​Program.cs Demonstrates Word-to-PDF conversion.
Examples/​ConvertDocxToPdf/​ConvertDocxToPdf.csproj Configures the Word project and document sample.
Examples/​CompressPdf/​Program.cs Compresses a PDF and reports before-and-after sizes.
Examples/​CompressPdf/​CompressPdf.csproj Configures the compression project and sample.
ConvertApi.sln Registers all seven projects under Examples.

Review effort: Balanced

@tomasr78
tomasr78 merged commit 5bbc540 into main Nov 11, 2026
4 checks passed
@tomasr78
tomasr78 deleted the examples-task-projects branch November 11, 2026 11:41
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