PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Oct 15, 2019 11:36 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jul 25, 2018 11:24 pm 
Offline

Joined: Sun Apr 15, 2018 4:52 pm
Posts: 4
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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 26, 2018 5:59 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 481
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 26, 2018 6:24 pm 
Offline

Joined: Sun Apr 15, 2018 4:52 pm
Posts: 4
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 27, 2018 6:23 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 481
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 407 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group