Skip to content

Class FacturXDocumentBuilder

Assembly: FacturXDotNet.dll
csharp
public class FacturXDocumentBuilder

Methods

SetLogger(ILogger?)

Set the logger that will be used during the call to FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.BuildAsync().

csharp
public FacturXDocumentBuilder SetLogger(ILogger? logger)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
Microsoft.Extensions.Logging.ILoggerloggerThe logger to use.

UsePdfGenerator(IPdfGenerator)

Sets the PDF generator to be used for creating the Factur-X document. Using this method will replace the currently set PDF generator and cancel any previous calls to FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.UsePdfGenerator(FacturXDotNet.Generation.PDF.IPdfGenerator), FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.WithStandardPdf() or FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.WithBasePdf(System.IO.Stream%2cSystem.Action%7bFacturXDotNet.Generation.FacturX.BasePdfStreamOptions%7d).

csharp
public FacturXDocumentBuilder UsePdfGenerator(IPdfGenerator generator)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
FacturXDotNet.Generation.PDF.IPdfGeneratorgeneratorThe PDF generator to use.

WithStandardPdf()

Sets the PDF generator of the builder to the standard generator. The standard generator is the default generator used when no custom generator is provided.

csharp
public FacturXDocumentBuilder WithStandardPdf()
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.### WithBasePdf(Stream, Action<BasePdfStreamOptions>?) Set the base PDF image for the Factur-X document. The builder will edit this PDF image to add the XMP metadata, the Cross Industry Invoice and other attachments, then save it to the output stream.

csharp
public FacturXDocumentBuilder WithBasePdf(Stream pdfImageStream, Action<BasePdfStreamOptions>? configure = null)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
System.IO.StreampdfImageStreamThe stream containing the base PDF image.
System.Action<FacturXDotNet.Generation.FacturX.BasePdfStreamOptions>configureAn optional action to configure the base PDF stream options, such as setting a password or indicating whether the stream should remain open after
processing.

WithCrossIndustryInvoice(CrossIndustryInvoice, Action<CrossIndustryInvoiceOptions>?)

Set the Cross Industry Invoice data for the Factur-X document. The data will be added as an attachment to the PDF document.

csharp
public FacturXDocumentBuilder WithCrossIndustryInvoice(CrossIndustryInvoice cii, Action<CrossIndustryInvoiceOptions>? configure = null)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
FacturXDotNet.Models.CII.CrossIndustryInvoiceciiThe Cross Industry Invoice (CII) data that contains the structured invoice details to be attached to the Factur-X document.
System.Action<FacturXDotNet.Generation.FacturX.CrossIndustryInvoiceOptions>configureAn optional action to configure additional options for the invoice attachment.

WithCrossIndustryInvoice(Stream, Action<CrossIndustryInvoiceStreamOptions>?)

Set the Cross Industry Invoice data for the Factur-X document. The data will be added as an attachment to the PDF document.

csharp
public FacturXDocumentBuilder WithCrossIndustryInvoice(Stream cii, Action<CrossIndustryInvoiceStreamOptions>? configure = null)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
System.IO.StreamciiThe Cross Industry Invoice data.
System.Action<FacturXDotNet.Generation.FacturX.CrossIndustryInvoiceStreamOptions>configureAn optional action to configure additional options for the invoice attachment.

WithXmpMetadata(XmpMetadata)

Set the XMP metadata for the Factur-X document. The metadata will be added as-is to the PDF document, it will replace any existing metadata found in the document.

csharp
public FacturXDocumentBuilder WithXmpMetadata(XmpMetadata xmp)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
FacturXDotNet.Models.XMP.XmpMetadataxmpThe XMP metadata.

WithXmpMetadata(Stream, Action<XmpMetadataStreamOptions>?)

Set the XMP metadata for the Factur-X document. The metadata will be added as-is to the PDF document, it will replace any existing metadata found in the document.

csharp
public FacturXDocumentBuilder WithXmpMetadata(Stream xmpStream, Action<XmpMetadataStreamOptions>? configure = null)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
System.IO.StreamxmpStreamThe stream containing the XMP metadata.
System.Action<FacturXDotNet.Generation.FacturX.XmpMetadataStreamOptions>configureAn optional action to configure additional options for the invoice attachment.

PostProcess(Action<FacturXDocumentPostProcessOptions>)

Post-process the XMP metadata after it has been added to the PDF document. The metadata is either provided as-is using one of the FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.WithXmpMetadata(FacturXDotNet.Models.XMP.XmpMetadata) overloads, or a combination of the existing metadata of the base PDF and the CII data.

csharp
public FacturXDocumentBuilder PostProcess(Action<FacturXDocumentPostProcessOptions> postProcess)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
System.Action<FacturXDotNet.Generation.FacturX.FacturXDocumentPostProcessOptions>postProcessThe action to perform on the XMP metadata.

WithAttachment(PdfAttachmentData, Action<AttachmentOptions>?)

Add an attachment to the Factur-X document.

csharp
public FacturXDocumentBuilder WithAttachment(PdfAttachmentData attachment, Action<AttachmentOptions>? configure = null)
Returns

FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder: The builder itself for chaining.

Parameters
TypeNameDescription
FacturXDotNet.Generation.PDF.PdfAttachmentDataattachmentThe attachment to add.
System.Action<FacturXDotNet.Generation.FacturX.AttachmentOptions>configureAn optional action to configure additional options for the invoice attachment.

BuildAsync()

Create a new Factur-X document.

csharp
public Task<FacturXDocument> BuildAsync()
Returns

System.Threading.Tasks.Task<FacturXDotNet.FacturXDocument>: The Factur-X document.## Extension Methods

  • FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.FacturXDotNet.Generation.FacturX.FacturXDocumentBuilderFileExtensions.WithBasePdfFile(System.String,System.String)
  • FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.FacturXDotNet.Generation.FacturX.FacturXDocumentBuilderFileExtensions.WithCrossIndustryInvoiceFile(System.String,System.String)
  • FacturXDotNet.Generation.FacturX.FacturXDocumentBuilder.FacturXDotNet.Generation.FacturX.FacturXDocumentBuilderFileExtensions.WithXmpMetadataFile(System.String)

The tools are open source and released under the MIT License, feel free to use, modify, and share.