Skip to content

Docs · Quick start

Quick start.

Install from a local folder feed, render a document, and handle what can go wrong. Every snippet on this page is the real API.

Install from the feed

There is no nuget.org package in this release. Put the folder feed where the build can read it, register it once, then reference the package by name and version.

terminalpowershell
dotnet nuget add source C:\feeds\xml2pdf -n xml2pdf-local

The path above is an example — use wherever you unpacked the feed.

App.csprojXML
<PropertyGroup>
  <TargetFramework>net10.0-windows</TargetFramework>
  <PlatformTarget>x64</PlatformTarget>
  <UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="AltSoft.Xml2Pdf" Version="1.0.0" />
</ItemGroup>
An AnyCPU or x86 project fails at build time with XML2PDF010; a non-win-x64 runtime identifier fails with XML2PDF011. The library has no NuGet dependencies of its own.

File conversion

The shortest path: one renderer, one call. The file appears at your output path only after the render succeeds — the library writes a temp file in the destination directory and moves it into place.

Program.csC#
using AltSoft.Xml2Pdf;

using var renderer = new FoPdfRenderer();
renderer.Convert("invoice.fo", "invoice.pdf");

The input is XSL-FO. Getting to know XSL-FO is the shortest introduction to the vocabulary, and XSL-FO document structure walks through the root element, the page masters and the flow that carry the content.

Stream conversion

For documents you generate in memory, hand over streams instead of paths.

Program.csC#
using var fo = File.OpenRead("invoice.fo");
using var pdf = File.Create("invoice.pdf");

using var renderer = new FoPdfRenderer();
renderer.Convert(fo, pdf);

The input stream does not need to be seekable. The output stream must be writable and seekable.

Stream output is not atomic. If a render fails mid-way, partial bytes may already be in the stream. Wrap or discard it, or write to a file when you need the temp-file guarantee.

Platform requirements

The platform surface is deliberately narrow. Anything outside it fails immediately rather than half-working.

Requiredspec
Target framework   net10.0-windows
Platform           Windows x64
Runtime            Microsoft.WindowsDesktop.App
Project flag       <UseWindowsForms>true</UseWindowsForms>
NuGet dependencies none

On a non-Windows or non-x64 host the constructor throws PlatformNotSupportedException — before any document is read.

Need another .NET version? XML2PDF has supported .NET Framework through .NET 5, and our latest release supports .NET 10. We maintain the original source code and can build for other .NET versions on request, at no extra cost with your Commercial + OEM licence, subject to technical feasibility. Core 1.0 itself is certified for .NET 10 on Windows x64; the older builds belong to the previous product line. See compatibility builds, or email support@alt-soft.com with your requirements.

Error handling

Conversion failures raise Xml2PdfException with an ErrorCode you can switch on. Platform failures are separate: they are not wrapped in Xml2PdfException.

Program.csC#
// inPath / outPath: the .fo input and the .pdf output for this call
try
{
    using var renderer = new FoPdfRenderer();
    renderer.Convert(inPath, outPath);
}
catch (Xml2PdfException ex)
{
    switch (ex.ErrorCode)
    {
        case ErrorCode.MissingInput:    // nothing at that path
        case ErrorCode.InvalidInput:    // document rejected
        case ErrorCode.FontUnavailable: // font could not be resolved
        case ErrorCode.StreamNotUsable: // output not writable/seekable
        case ErrorCode.EngineFailure:   // renderer failed internally
            Console.Error.WriteLine($"{ex.ErrorCode}: {ex.Message}");
            throw;
    }
}
ErrorCode values raised by Xml2PdfException, with their meaning
ErrorCodeMeaning
InvalidInputThe input document was rejected as invalid.
MissingInputThe input file or stream was not supplied or not found.
FontUnavailableA font the conversion required could not be resolved.
StreamNotUsableThe output stream is not writable or not seekable.
EngineFailureThe renderer failed internally.
Fonts get their own note. A font that a document names but the host lacks is substituted, not raised as an error — see the next section.

Fonts

System fonts are the default. Pass an array of folders to the constructor, and use the two tokens the engine understands for the platform font set.

Program.csC#
using var renderer = new FoPdfRenderer(new[]
{
    @"C:\Corp\Fonts",
    "%SystemFonts%",
    "%StdPDFType1Fonts%"
});

An unavailable font is replaced by a substitute and the page still renders; it is not reported as a failure. Proof a representative document before you ship — the substitute decides how the page looks, not the document.

How fonts, sizes and inline text are declared in the document itself is covered by Font and text attributes.

Threading

The renderer is not thread-safe. Use one instance per conversion; a second concurrent call on the same instance throws InvalidOperationException. Parallelism across separate instances is not claimed.

Program.csC#
// files: the .fo documents to convert
foreach (var file in files)
{
    using var renderer = new FoPdfRenderer();
    renderer.Convert(file, Path.ChangeExtension(file, ".pdf"));
}

Known restrictions

Documented limits, stated as they are.

  • Windows x64 only. No Linux, macOS or ARM64 build; no .NET Framework 4.8 support in this release.
  • Same input, same layout, different bytes per run — timestamps and font-subset identifiers differ between files.
  • No XSL-FO conformance level is asserted. Capability is evidenced by a 22-document regression corpus, not a compliance claim.
  • No performance targets are published. The renderer is built for correctness, not throughput.
  • One input format, one output format: XSL-FO in, PDF out. No Office, HTML, SVG or MathML.

Embedding, redistribution and updates

A Commercial licence covers one legal entity: unlimited developers, applications and deployments. You may redistribute the unmodified compiled AltSoft.Xml2Pdf dependency inside the applications you ship, royalty-free.

  • Covered: unlimited applications, unlimited customer installations, and hosted deployments you operate.
  • Not covered: reselling the library as a competing SDK, or redistributing modified engine assemblies.
  • 12 months of released updates are included; the version you bought keeps working afterwards.
  • The library is offline: no keys, activation, telemetry, network calls or call-home.