Skip to content

A document generation helper library for .NET apps. Uses the visitor pattern. Visitors are included for FlowDocuments and HTML.

Notifications You must be signed in to change notification settings

nkratzmeyer/CypressDocTree

Repository files navigation

CypressDocTree

Synopsis

CypressDocTree is a logical document tree generator uitilizing the Composite and Visitor patterns. The library allows you to generate a simple Document Object tree without specifying how the tree will be rendered. Only a bare minimum of presentational elements are included in the library. The actual rendering of the document would be done via the use of an IDocumentVisior. A sample HTMLVisitor and FlowdocumentVisitor are provided with the library and can be used to generate simple HTML or WPF Flowdocuments. Other types of Visitors (i.e. PDF, plaintext, VTS, etc.) could be coded by the client to render the document tree as desired.

Code Example

//Usage
//First construct the document tree
CyDocument doc = new CyDocument();
CyHeading heading = new CyHeading("TEST HEADING");
doc.AddChild(heading);
CyParagraph paragraph = new CyParagraph("This is a test paragraph");
doc.AddChild(paragraph);

//Render the document as flowdocument
FlowDocument fd = new FlowDocument();
FlowDocumentVisitor flowDocVisitor = new FlowDocumentVisitor(fd);
flowDocVisitor.Visit(doc);
//At this point, fd has been populated and can be used elsewhere

//Render the document as HTML
HTMLVisitor htmlVisitor = new HTMLVisitor();
htmlVisitor.visit(doc);
string html = htmlVisitor.HTML;

Motivation

I started the project as a way to simplify document creation in several different formats.

Contributors

Please feel free to contribute or provide constructive criticism.

License

MIT License

About

A document generation helper library for .NET apps. Uses the visitor pattern. Visitors are included for FlowDocuments and HTML.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages