This directory contains console application examples demonstrating various features of the Gotenberg Sharp API Client.
-
Gotenberg Server: You need a running Gotenberg instance with basic authentication. See the main README for setup instructions.
The examples are pre-configured to use the docker-compose setup with basic auth:
docker-compose -f docker/docker-compose-basic-auth.yml up -d
-
.NET 8.0 SDK: All examples target .NET 8.0.
All examples share a common configuration file: appsettings.json
The default configuration includes:
- Service URL:
http://localhost:3000 - Basic Auth: Username
testuser, Passwordtestpass(matching docker-compose-basic-auth.yml) - Retry Policy: Enabled with 4 retries and exponential backoff
You can modify these settings in appsettings.json or update the credentials directly in the example code.
Converts HTML to PDF with embedded assets.
cd HtmlConvert
dotnet run [output-directory]Demonstrates dependency injection setup with logging and Polly retry policy.
cd DIExample
dotnet run [output-directory]Merges multiple PDF files into a single PDF.
cd PdfMerge
dotnet run [source-directory] [output-directory]Converts multiple URLs to PDFs and merges them into a single document. Creates a news summary from major news sites.
Note: Requires increased Gotenberg timeout (--api-timeout=1800s)
cd UrlsToMergedPdf
dotnet run [output-directory]Converts HTML containing Markdown to PDF.
cd HtmlWithMarkdown
dotnet run [output-directory]Merges Office documents (Word, Excel, PowerPoint) into a single PDF.
cd OfficeMerge
dotnet run [source-directory] [output-directory]Converts a URL to PDF with custom header and footer.
cd UrlConvert
dotnet run [output-directory]Demonstrates webhook functionality for async PDF generation.
Note: Requires a webhook receiver API running on localhost:5000
cd Webhook
dotnet runConverts PDF files to PDF/A formats (A1a, A2b, A3b).
cd PdfConvert
dotnet run [source-directory] [output-directory]- Directory.Build.props: Shared configuration for all example projects (target framework, dependencies, resources)
- appsettings.json: Shared Gotenberg client configuration
- resources/: Shared resource files used by the examples (HTML templates, images, Office documents, etc.)
Each example can be run independently. Most examples accept optional command-line arguments for specifying input/output directories. If no arguments are provided, they use sensible defaults (usually ./output for generated files).
Example:
cd PdfMerge
dotnet run C:\MyPdfs C:\Output