MigraDocXML 3.0.0
dotnet add package MigraDocXML --version 3.0.0
NuGet\Install-Package MigraDocXML -Version 3.0.0
<PackageReference Include="MigraDocXML" Version="3.0.0" />
paket add MigraDocXML --version 3.0.0
#r "nuget: MigraDocXML, 3.0.0"
// Install MigraDocXML as a Cake Addin #addin nuget:?package=MigraDocXML&version=3.0.0 // Install MigraDocXML as a Cake Tool #tool nuget:?package=MigraDocXML&version=3.0.0
MigraDocXML
Introduction
From having to do a fair amount of work producing PDFs, I found MigraDoc is currently the only really viable open source .NET option available. It includes some excellent features that give a lot of control over creating PDFs, while still staying high level enough to be easy to understand.
However, the way document designs are written does also present some major drawbacks:
- Languages like C#/VB.NET just aren't well suited to the hierarchical nature of building up a display object model, and creating anything beyond a simple layout can quickly become a real challenge to remain readable. Other XML based languages such as HTML & XAML have proven that XML is far better suited to this sort of work.
- Document designs are stuck within your project assembly. This prevents quick design changes without recompiling your code, also making it much harder to have a product that ships to multiple customers, where each customer has their own requirements for PDF exports.
- Your programmers shouldn't be creating PDF reports. As a programmer, writing PDF designs is just plain boring, most of what you're writing is very boilerplate stuff, often plugging in slightly different numbers and recompiling to see if things finally line up right. MigraDocXML has been designed to be usable by people who don't come from a programming background but are willing to learn a few basic concepts.
MigraDocXML aims to solve these problems, while still keeping as much flexibility as possible. Below are some of its features:
- Supports inserting data from JSON, CSV or XML files, as well as directly from .NET objects
- MigraDoc's styling has been completely redesigned, with MigraDocXML offering a full cascading style system
- Designs can define their own variables, conditional and iterative logic. It also includes EvalScript, a lightweight expression evaluator which provides a lot of advanced language features. These combine to allow the easy writing of flexible designs that can adapt to your data
- Resources (stored either internally or externally) support code reuse
- Bridges the gap between MigraDoc & PDFSharp, allowing for the addition of custom drawings to your designs
- Includes an extension library that makes use of ZXing.NET to support inserting barcodes
Example
Below is a demonstration of a layout file which takes in a json file to produce this.
json:
{
"Name": "MigraDocXML",
"Positives": [
"Simple to learn",
"Easily readable design layouts",
"Full cascading style system",
"Support for PDFSharp graphics",
"Includes a powerful lightweight expression evaluator",
"Regular updates"
],
"Negatives": [
]
}
xml:
<?xml version="1.0"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://gitlab.com/jamescoyle/MigraDocXML/raw/master/MigraDocXML/schema.xsd">
<Style Target="p">
<Setters Format.Font.Name="Calibri" Format.SpaceBefore="2mm" Format.SpaceAfter="2mm"/>
</Style>
<Style Target="p" Name="Heading">
<Setters Format.Font.Bold="true" Format.Font.Underline="Single"/>
</Style>
<Section>
<p Style="Heading" Format.Font.Size="15" Format.Alignment="Center">Reasons you should use {Model.Name}</p>
<p Style="Heading">Positives:</p>
<ForEach Var="positive" In="Model.Positives.OrderByDesc(x => x.Length)">
<p>{positive}</p>
</ForEach>
<p Style="Heading">Negatives:</p>
<ForEach Var="negative" In="Model.Negatives">
<p>{negative}</p>
</ForEach>
</Section>
</Document>
Editor
MigraDocXML also includes a small WPF app for easily previewing the effect of changes to the layout or data on your output PDF. You can use the incredibly basic text editors included in the app, or, use whichever one you normally do. Either way, each time you save changes to your documents, the PDF will automatically get regenerated.
Sponsors
Part of the development of MigraDocXML is kindly sponsored by:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- EvalScript (>= 2.7.1)
- PDFsharp-MigraDoc (>= 6.1.1)
-
net6.0
- EvalScript (>= 2.7.1)
- PDFsharp-MigraDoc (>= 6.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MigraDocXML:
Package | Downloads |
---|---|
MigraDocXML-ZXing
An extension library for MigraDocXML, adding barcode support using ZXing.NET (https://github.com/micjahn/ZXing.Net). |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 325 | 9/2/2024 |
2.9.3 | 12,686 | 3/3/2023 |
2.9.2 | 292 | 2/28/2023 |
2.9.1 | 505 | 2/20/2023 |
2.9.0 | 5,581 | 2/6/2022 |
2.8.0 | 333 | 12/11/2021 |
2.7.2 | 1,585 | 10/21/2021 |
2.7.1 | 559 | 9/29/2021 |
2.7.0 | 512 | 9/7/2021 |
2.6.11 | 2,226 | 10/11/2020 |
2.6.10 | 664 | 8/29/2020 |
2.6.9 | 752 | 5/9/2020 |
2.6.6 | 1,939 | 3/30/2020 |
2.6.5 | 1,228 | 10/7/2019 |
2.6.3 | 6,008 | 7/14/2019 |
2.6.2 | 2,020 | 7/8/2019 |
2.6.1 | 996 | 7/5/2019 |
2.6.0 | 1,020 | 7/5/2019 |
2.5.0 | 1,032 | 6/5/2019 |
2.4.2 | 1,032 | 5/17/2019 |
2.4.1 | 1,006 | 5/14/2019 |
2.4.0 | 635 | 5/12/2019 |
2.3.0 | 1,416 | 4/22/2019 |
2.2.2 | 1,049 | 4/3/2019 |
2.2.1 | 1,031 | 3/17/2019 |
2.1.2 | 1,142 | 2/19/2019 |
2.1.1 | 1,103 | 2/17/2019 |
2.1.0 | 1,184 | 2/6/2019 |
2.0.0 | 1,284 | 1/24/2019 |
1.0.8 | 1,024 | 10/21/2018 |
Added support for annotations