DocumentToPdfConverter 1.0.4

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

DocumentToPdfConverter

High-performance open-source .NET library for converting office documents to PDF using LibreOffice headless. Supports DOC, DOCX, XLS, XLSX, ODT, ODS, PPT, PPTX.

License: MIT. Dependencies are MIT/Apache-2.0/BSD compatible. No proprietary libraries (Aspose, IronPDF, Syncfusion, Spire, etc.).


English

Requirements

  • .NET 8+
  • LibreOffice installed and soffice available on the system (or set SOFFICE_PATH).
    Linux (server/workstations): see INSTALLATION-LINUX.

Installation

dotnet add package DocumentToPdfConverter

Using the package

  1. Ensure LibreOffice is installed (or set SOFFICE_PATH).
  2. Create a converter and call ConvertAsync:

Quick start

using DocumentToPdfConverter;
using DocumentToPdfConverter.LibreOffice;
using Microsoft.Extensions.Options;

var options = new LibreOfficeConverterOptions
{
    ProcessTimeout = TimeSpan.FromSeconds(120),
    MaxConcurrency = 1,
};
await using var converter = new LibreOfficeConverter(Options.Create(options));

var result = await converter.ConvertAsync("input.docx", "output.pdf");
if (result.Success)
    Console.WriteLine($"Converted in {result.Duration.TotalSeconds:F1}s, size: {result.OutputSizeBytes} bytes");

Converting a file from command line (sample)

With LibreOffice installed, you can use the ConsoleApp sample:

dotnet run --project samples/ConsoleApp/ConsoleApp.csproj -- "path/to/document.docx" "path/to/output.pdf"

Example:

dotnet run --project samples/ConsoleApp/ConsoleApp.csproj -- "C:\Users\YourName\Downloads\Technical Specification.docx" "C:\Users\YourName\Downloads\Technical Specification.pdf"

Dependency injection

services.AddDocumentToPdfConverter(opt =>
{
    opt.ProcessTimeout = TimeSpan.FromSeconds(120);
    opt.MaxConcurrency = 2;
});
// Registers IDocumentConverter and a health check named "libreoffice"

API overview

  • ConvertAsync(path, path) – convert a file to a PDF file.
  • ConvertAsync(stream, stream, documentType) – convert from/to streams.
  • ConvertAsync(ReadOnlyMemory<byte>, documentType, IBufferWriter<byte>) – convert in-memory.
  • IsAvailableAsync() – check if LibreOffice is available.
  • GetLibreOfficeInfoAsync() – get version and path of the detected installation.

Full usage guide: docs/USAGE.md — all overloads, options, DI, error handling.

See TROUBLESHOOTING for common issues and configuration tips.
Install LibreOffice on Linux (Ubuntu/Debian, RHEL, server group).
Publish package to NuGet.org.


Русский

Требования

  • .NET 8+
  • Установленный LibreOffice, в системе доступна команда soffice (или задана переменная окружения SOFFICE_PATH).
    Linux (сервер/рабочие станции): см. INSTALLATION-LINUX.

Установка

dotnet add package DocumentToPdfConverter

Использование пакета

  1. Убедитесь, что установлен LibreOffice (или задана переменная SOFFICE_PATH).
  2. Создайте конвертер и вызовите ConvertAsync:

Быстрый старт

using DocumentToPdfConverter;
using DocumentToPdfConverter.LibreOffice;
using Microsoft.Extensions.Options;

var options = new LibreOfficeConverterOptions
{
    ProcessTimeout = TimeSpan.FromSeconds(120),
    MaxConcurrency = 1,
};
await using var converter = new LibreOfficeConverter(Options.Create(options));

var result = await converter.ConvertAsync("input.docx", "output.pdf");
if (result.Success)
    Console.WriteLine($"Конвертировано за {result.Duration.TotalSeconds:F1} с, размер: {result.OutputSizeBytes} байт");

Конвертация файла из командной строки (пример)

При установленном LibreOffice можно использовать пример ConsoleApp:

dotnet run --project samples/ConsoleApp/ConsoleApp.csproj -- "путь/к/документу.docx" "путь/к/результату.pdf"

Пример:

dotnet run --project samples/ConsoleApp/ConsoleApp.csproj -- "C:\Users\Имя\Downloads\Техническая спецификация.docx" "C:\Users\Имя\Downloads\Техническая спецификация.pdf"

Регистрация в DI

services.AddDocumentToPdfConverter(opt =>
{
    opt.ProcessTimeout = TimeSpan.FromSeconds(120);
    opt.MaxConcurrency = 2;
});
// Регистрирует IDocumentConverter и проверку здоровья "libreoffice"

Обзор API

  • ConvertAsync(path, path) — конвертация файла в PDF.
  • ConvertAsync(stream, stream, documentType) — конвертация из потока в поток.
  • ConvertAsync(ReadOnlyMemory<byte>, documentType, IBufferWriter<byte>) — конвертация в памяти.
  • IsAvailableAsync() — проверка доступности LibreOffice.
  • GetLibreOfficeInfoAsync() — получение версии и пути к установленному LibreOffice.

Подробная инструкция по использованию: docs/USAGE.md — все перегрузки, опции, DI, обработка ошибок.

Подробнее о типичных проблемах и настройке: TROUBLESHOOTING.
Установка LibreOffice на Linux (Ubuntu/Debian, RHEL, группа серверов).
Публикация пакета в NuGet.org.

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.4 378 2/25/2026
1.0.3 59 2/19/2026
1.0.2 80 2/18/2026
1.0.1 62 2/18/2026

Initial release. Converts DOC, DOCX, XLS, XLSX, ODT, ODS, PPT, PPTX to PDF via LibreOffice headless. File, stream, and in-memory conversion. Process pool with configurable concurrency. DI extension and health check. MS Office font mapping: Calibri→Carlito, Cambria→Caladea, Arial→Liberation Sans, Times New Roman→Liberation Serif (avoids DejaVu by default); disable with ApplyMsOfficeFontMapping = false. MIT license.