PDFs on Mono

Oystein Bjorke 6 years ago 0
This discussion was imported from CodePlex

evolvedmicrobe wrote at 2013-07-17 17:50:


I wanted to run by/suggest some ideas for getting oxyplot to work on mono.

Right now, the PDF generation fails in mono because PDFSharp uses the User32.dll file to get some binary information to embed in the PDF for the various fonts. Myself and others have tried to work around this by either 1) Embedding the font information ahead of time in the PDF assembly, or 2) Grabbing the information directly from the font files on the local machine in a platform specific way.

Unfortunately, it seems that the results are still not up to par... and the rendering is much better on windows. I think this might have to do with the GDI library in mono not behaving the same way as the windows one, but it's a pretty buried problem and I can't track it down.

I was thinking of investing more time in it, but it also seemed to me that perhaps just switching over to a different PDF generating library, such as iTextSharp, to do the rendering. It seems shapes are possible as in here:


I wanted to ask if other people have attempted PDF rendering on Mono though, to see if they had any insights on the ease or feasibility of either:

1) Trying to switch to iTextSharp
2) Trying to get PDFSharp to render correctly.
3) Deciding the problem is too much work to invest in.

Does anyone have any thoughts or experience in how hard any of these might be? (hours/days??)

objo wrote at 2013-07-19 08:24:

Note that iText is licensed under AGPL. See the license terms.

I would like to see the following changes rather than spending time on iTextSharp and PDFSharp
  • change OxyPlot text rendering so text alignment does not depend on text measurements
  • include a small pdf exporter that can render lines, fill polygons and render text in the OxyPlot core library (PCL). I did some prototyping some time ago, and it seems feasible (but the text/font handling is probably the hardest part). See pdf reference

evolvedmicrobe wrote at 2013-07-25 17:22:

hmm, agreed it would probably be better to move away from iText or PDFSharp.

I wound up using a hacked version of pdfsharp described here: http://forum.pdfsharp.net/viewtopic.php?f=4&t=1206&p=7289#p7289 that works, provided one tells it where to find the fonts on the local system, which is something of a pain. I don't think embedding the fonts works either because mono uses X11 to do the drawing, and they may not match.

Looks like this is more than I can handle now though so will have to leave the issue for now. Thanks for the response though!