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.
dotnet nuget add source C:\feeds\xml2pdf -n xml2pdf-localThe path above is an example — use wherever you unpacked the feed.
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AltSoft.Xml2Pdf" Version="1.0.0" />
</ItemGroup>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.
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.
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.
Platform requirements
The platform surface is deliberately narrow. Anything outside it fails immediately rather than half-working.
Target framework net10.0-windows
Platform Windows x64
Runtime Microsoft.WindowsDesktop.App
Project flag <UseWindowsForms>true</UseWindowsForms>
NuGet dependencies noneOn a non-Windows or non-x64 host the constructor throws PlatformNotSupportedException — before any document is read.
Error handling
Conversion failures raise Xml2PdfException with an ErrorCode you can switch on. Platform failures are separate: they are not wrapped in Xml2PdfException.
// 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 | Meaning |
|---|---|
| InvalidInput | The input document was rejected as invalid. |
| MissingInput | The input file or stream was not supplied or not found. |
| FontUnavailable | A font the conversion required could not be resolved. |
| StreamNotUsable | The output stream is not writable or not seekable. |
| EngineFailure | The renderer failed internally. |
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.
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.
// 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.