TabTabGo.Service.Generator 1.0.0

dotnet add package TabTabGo.Service.Generator --version 1.0.0
                    
NuGet\Install-Package TabTabGo.Service.Generator -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TabTabGo.Service.Generator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TabTabGo.Service.Generator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TabTabGo.Service.Generator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TabTabGo.Service.Generator --version 1.0.0
                    
#r "nuget: TabTabGo.Service.Generator, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TabTabGo.Service.Generator@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TabTabGo.Service.Generator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TabTabGo.Service.Generator&version=1.0.0
                    
Install as a Cake Tool

TabTabGo.Service.Generator

A .NET 8 SDK for the TabTabGo PDF Generator service.

Instead of writing raw HttpClient calls, handling API-key headers, serialization, and logging yourself, this package provides a strongly-typed client that does it all for you.

Installation

dotnet add package TabTabGo.Service.Generator

Configuration

appsettings.json

{
  "GeneratorService": {
    "BaseUrl": "https://your-pdf-generator-host",
    "ApiKey": "your-api-key",
    "Timeout": "00:00:30"
  }
}

Program.cs / Startup.cs

// Bind from configuration section (recommended for production)
builder.Services.AddGeneratorClient(
    builder.Configuration.GetSection(GeneratorOptions.SectionName));

// Or configure inline (useful for testing / simple apps)
builder.Services.AddGeneratorClient(opts =>
{
    opts.BaseUrl = "https://your-pdf-generator-host";
    opts.ApiKey  = "your-api-key";
});

Usage

Inject IGeneratorClient wherever you need it:

public class MyService
{
    private readonly IGeneratorClient _generator;

    public MyService(IGeneratorClient generator)
    {
        _generator = generator;
    }

    // HTML → PDF
    public async Task<byte[]> HtmlToPdfAsync(string html)
    {
        return await _generator.GeneratePdfFromHtmlAsync(html, new PdfOptions
        {
            Format = "A4",
            PrintBackground = true,
            Margin = new PdfMargin { Top = "1cm", Bottom = "1cm", Left = "1cm", Right = "1cm" }
        });
    }

    // DOCX → PDF  (pass the file as base64)
    public async Task<byte[]> DocxToPdfAsync(byte[] docxBytes)
    {
        var base64 = Convert.ToBase64String(docxBytes);
        return await _generator.GeneratePdfFromDocxAsync(base64);
    }

    // Word XML → PDF
    public async Task<byte[]> WordXmlToPdfAsync(string wordXml)
    {
        return await _generator.GeneratePdfFromWordXmlAsync(wordXml);
    }
}

PDF Options

All PdfOptions properties are optional:

Property Type Description
Format string? Paper format: "A4", "Letter", etc.
Width string? Paper width, e.g. "210mm"
Height string? Paper height, e.g. "297mm"
PrintBackground bool? Include background graphics
Landscape bool? Landscape orientation
PageRanges string? Page ranges, e.g. "1-5, 8"
PreferCssPageSize bool? Use CSS-defined page size
DisplayHeaderFooter bool? Show header/footer
HeaderTemplate string? HTML header template
FooterTemplate string? HTML footer template
Margin PdfMargin? Page margins (Top, Right, Bottom, Left)

Error Handling

If the service returns a non-success HTTP response, a GeneratorServiceException is thrown:

try
{
    var pdf = await _generator.GeneratePdfFromHtmlAsync(html);
}
catch (GeneratorServiceException ex)
{
    Console.WriteLine($"Service error {ex.StatusCode}: {ex.ResponseBody}");
}

License

ISC

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 124 3/27/2026