Invoices
The invoice generator service creates a basic PDF. You can replace the service for fully custom invoicing. Our default implementation will be customisable through the CMS in a future update.
Replacing the DocumentGeneratorService
Implement IDocumentGeneratorService, for example:
public class CustomDocumentGeneratorService : IDocumentGeneratorService
{
public async Task<GeneratedDocumentResponse> GenerateInvoice(Order order)
{
var memoryStream = new MemoryStream();
// ...
return new GeneratedDocumentResponse()
{
ContentType = "application/pdf",
Name = "invoice.pdf",
Stream = memoryStream,
};
}
public async Task<GeneratedDocumentResponse> GeneratePackingSlip(Order order)
{
// ...
}
}
Now register this as a singleton using a composer:
public class CustomDocumentGeneratorComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.AddSingleton<IDocumentGeneratorService, CustomDocumentGeneratorService>();
}
}