Swiss.FCh.DocumentService.Client 1.8.2

Prefix Reserved
dotnet add package Swiss.FCh.DocumentService.Client --version 1.8.2
                    
NuGet\Install-Package Swiss.FCh.DocumentService.Client -Version 1.8.2
                    
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="Swiss.FCh.DocumentService.Client" Version="1.8.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Swiss.FCh.DocumentService.Client" Version="1.8.2" />
                    
Directory.Packages.props
<PackageReference Include="Swiss.FCh.DocumentService.Client" />
                    
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 Swiss.FCh.DocumentService.Client --version 1.8.2
                    
#r "nuget: Swiss.FCh.DocumentService.Client, 1.8.2"
                    
#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 Swiss.FCh.DocumentService.Client@1.8.2
                    
#: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=Swiss.FCh.DocumentService.Client&version=1.8.2
                    
Install as a Cake Addin
#tool nuget:?package=Swiss.FCh.DocumentService.Client&version=1.8.2
                    
Install as a Cake Tool

Introduction

This library simplyfies the usage of the DocumentService which is run by the federal chancellery.

usage

DI Injection

First, register the service in you DI container.

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDocumentService(builder.Configuration);

Health Check

Add a health check for the document service.

builder.Services
       .AddHealthChecks()
       .AddDocumentService();

Configuration

In your appsettings, add the following.

{
    "DocumentService": {
	    "Url": "ds_service_url",
		"TokenUrl": "http://might_be_your_key_cloak/realms/bk-micro-services/protocol/openid-connect/token",
		"ClientId": "your_client_id",
		"ClientSecret": "your_client_secret",
		"RequestTimeoutMs": your_timeout
	}
}

Excel Generation

Generate an Excel sheet like this.

		var spreadsheet = new Spreadsheet
        {
            HeaderCells = [...]
            BodyCells = [...],
            TableOptions = new TableOptions
            {
                CreateTable = true,
                ShowTotalsRow = true
            }
        };

        var resultStream = await _documentService.CreateExcel(spreadsheet);

Template Generation

Generate a document based on an Aspose LINQ Syntax Template.

//generate a Word document
var resultingWordDoc = await _documentService.CreateWordFromTemplate($"pathToYourTemplate.docx", dataObject, "yourDataObjectRootElementName");

//generate a PDF
var resultingPdf = await _documentService.CreateWordFromTemplate($"pathToYourTemplate.docx", dataObject, "yourDataObjectRootElementName");

Note that your dataObject can be any object (it will be serialized to JSON and should match the placeholders in your word template).

Word to HTML Conversion

You can convert a Word document to HTML as follows.

var result = await _documentService.ConvertWordToHtml("your_word_file_path");

Extract Parts of a Document

You can extract parts of a Word document as follows.

var result = await _documentService.ExtractContentFromWord("your_word_file_path", new WordExtractOptions { .. });

The WordExtractOptions allow to configure the following.


|Property | Description | |StartAfterParagraphText | Start the extraction after this text has occured (paragraph "starts with"). | |StopBeforeParagraphText | Stop the extraction before this text has occured (paragraph "starts with)". | |ExactStart | Start the extraction after this text has occured (paragraph must match exaclty). | |ExactEnd | Stop the extraction before this text has occured (paragraph must match exactly). | |WordExtractFormat | Extract result as HTML or PDF | |LineBreaks | Allow soft linebreaks in the search pattern | |RemoveClasses | Removes all CSS classes from the resulting HTML | |RemoveStyles | Removes all styles from the resulting HTML | |RemoveImages | Removes images from the result | |RemoveEmptyAnchors | Removes all <a> tags with no href | |RemoveSpans | Removes all <span> but keeps their content | |ReplaceItalicWithEmphasis | Replaces <i> with <em> in the result HTML | |ReplaceBoldWithStrong | Replaces <b> with <strong> in the result HTML |

Contribution

See: https://github.com/swiss/fch-documentservice-client/blob/main/CONTRIBUTING.md

Security

See: https://github.com/swiss/fch-documentservice-client/blob/main/SECURITY.md

Development Workflow

To publish a new version of the NuGet package, proceed as follows.

  • apply and push your changes
  • define and describe the new version in CHANGELOG.md
  • push the corresponding label with git tag vx.x.x and git push origin vx.x.x
  • go to GitHub → Actions → 'Build and Publish to NuGet.org' and trigger a run while specifying the correct GIT label
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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

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.8.2 247 3/12/2026
1.8.1 104 3/11/2026