PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

GDI vs WPF DocumentObjectModel assemblies
http://forum.pdfsharp.com/viewtopic.php?f=2&t=3816
Page 1 of 1

Author:  James Coyle [ Wed Jul 25, 2018 11:24 pm ]
Post subject:  GDI vs WPF DocumentObjectModel assemblies

Hi all, I'm having a little frustration with MigraDoc at the moment after not touching it for a while. First a little background, I've written my own library that wraps MigraDoc to allow for writing it as markup. The only part of MigraDoc it's using is the DocumentObjectModel, all the other stuff regarding rendering is not needed for the library.

So far things are working great with the GDI assemblies, I'd now like to try allowing support for WPF as well. This is where I have a problem, since my library is referencing MigraDoc.DocumentObjectModel, not MigraDoc.DocumentObjectModel-WPF, meaning the WPF rendering classes don't like any of the objects I'm outputting. This is despite the fact that having looked at the MigraDoc source code, they are actually the exact same classes, in the exact same namespace, just from different assemblies.

First of all, does anyone know why the projects have been structured like this? Wouldn't it be far easier if there were just one DocumentObjectModel assembly that gets referenced by the various different rendering assemblies? Surely the choice of rendering method is not important on the DOM.

Secondly, is there any way around this? I've tried looking at solutions such as AutoMapper to map from the objects in one assembly to the other, but since they share the same namespace, I'm getting clashes and can't actually define which version of the classes I want to convert from/to.

Any help greatly appreciated
James

Author:  TH-Soft [ Thu Jul 26, 2018 5:59 am ]
Post subject:  Re: GDI vs WPF DocumentObjectModel assemblies

Hi!

The source code files are the same, but the code may differ due to conditional compiling.
Differences in the DOM probably make no sense, but there could be some.

Printing only works with the GDI build. I used MDDDL files to convert from one DOM to the other.
See also:
viewtopic.php?f=8&t=3202

Author:  James Coyle [ Thu Jul 26, 2018 6:24 pm ]
Post subject:  Re: GDI vs WPF DocumentObjectModel assemblies

Hey! Thanks for the info. Your comment on possible conditional compiling in the MigraDoc DOM libraries does worry me a little bit, though so long as the public interfaces are the same between the 2 versions hopefully things won't get too complicated. Also, regarding the printing, I'm not so worried about that for the time being, since I'm purely focusing on using markup to build up the DOM, anything after that isn't going to be handled.

Sounds like an interesting approach using MDDDL files to convert between versions, I hadn't actually considered that as an option yet. Currently I'm looking to try creating a WPF version of my library which includes all the classes from my main library but just references the WPF version of MigraDoc instead of the GDI. Since the namespace is the same between the 2 versions, hopefully things should quite nicely slot themselves together, then I just need to remember to update my WPF project file whenever I add a new class to my main project. I'll update later with the results of this little experiment.

James

Update: It seems to have worked. I now have versions of my library that work with both GDI & WPF with very little hassle involved.

Author:  TH-Soft [ Fri Jul 27, 2018 6:23 am ]
Post subject:  Re: GDI vs WPF DocumentObjectModel assemblies

James Coyle wrote:
Also, regarding the printing, I'm not so worried about that for the time being [...]
Printing was the area where I had to share documents between the two DOMs, and solved it using MDDDL. I understand your problem was not printing, but sharing documents between the two DOMs.

Good to hear you got it working.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/