PDFsharp & MigraDoc Foundation

MigraDoc Document Object Model Heirarchy
Page 1 of 1

Author:  benfosterdev [ Thu May 09, 2013 10:48 pm ]
Post subject:  MigraDoc Document Object Model Heirarchy

Hey guys,

I'm working on a Markdown and HTML to PDF converter that builds on top of the MigraDoc Document Object Model.

One issue that I've come up across is that there does not need to be a common interface between related Document Elements - the only thing we have is DocumentObject which is too low level for building the PDF.

An example would be Hyperlinks and Paragraphs. Both objects can contain other elements (they both have a ParagraphElements property). However, since they don't share a common interface I have to check explicitly for the element type when doing a conversion. Likewise both Paragraphs and Sections can contain Images but neither share a common interface.

It would be much better if interfaces were used to drive the design of the API. Currently there are lots of duplicate functions on related elements. If these shared common interfaces, the Add* methods could simply be extension methods.

If you are open to this I'd be happy to send a spike of what I am proposing. Also, could you explain what is the functional difference between DocumentObjectCollection, DocumentElements and ParagraphElements - it seems to be me that the only difference is the Add* methods they expose; yet they don't actually restrict what can be added to the underlying collection - for example, I can add a Paragraph to another Paragraph but it will blow up when I try and render the document.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group