IDocumentFormatter.CreateMinifier Method
- Namespace
- Kampute.DocToolkit.Formatters
- Assembly
- Kampute.DocToolkit.dll
Definition
Creates a TextWriter instance that wraps the specified writer to minimize the content for the target format.
TextWriter CreateMinifier(TextWriter writer)Parameters
writerTextWriter- The TextWriter to write the minimized content to.
Returns
- TextWriter
- A new instance of TextWriter that wraps the specified writer for minimizing the content, or the original writer if the target format does not support minimization.
Remarks
Examples
Here is an example of how to use the IDocumentFormatter.CreateMinifier(TextWriter) method:
using var minifiedWriter = formatter.CreateMinifier(textWriter);
using var markupWriter = formatter.CreateMarkupWriter(minifiedWriter);
markupWriter.WriteHeading("Title", 1);
markupWriter.WriteParagraph("This is properly encoded content for the target format.");

If the target format supports minimization, this method returns a new TextWriter that wraps the specified writer. The wrapper instance takes ownership of the specified writer and will dispose it when the wrapper is disposed. If the target format does not support minimization, the original writer is returned.