Search code examples
c#wpflatexpdflatex

Creating a LaTeX Document in C#/WPF Application


Has anyone ever created a .pdf document within their C#/WPF application using LaTeX? We're creating reports and displaying them to the screen and we've looked into creating the reports with HTML and LaTeX. The HTML option is easy, but creating a LaTeX document within C# seems non-trivial which I personally find a bit odd; I'd think people have done this many times before. Anyone know of any LaTeX libraries to look at or some other way of doing it?


Solution

  • I'm not aware of any LaTeX libraries and like you said it doesn't seem to be trivial to do so which I also find a bit strange. I've always written the documents myself using the TeXnic Center IDE which I've found really useful.

    You could always try writing the source for the document to a file using a StreamWriter and then run a new pdflatex process through the command prompt in code to compile the document to a pdf?

    Other than that I did manage to stumble across a list of open source pdf generating libraries for C# which might be worth taking a look at here (I don't think any of them are for LaTeX unfortunately):

    http://en.csharp-online.net/Open_Source_PDF_Libraries

    iTextSharp seems to be recommended quite a lot by people so it might be worth looking at that. Hopefully somebody else will be able to point you towards a LaTeX library but if they can't and running the pdflatex as a process through your code isn't viable then atleast these might give you a decent alternative.

    Hope this helps.