Blog speaking .Net C# Javascript, Wordpress

How to convert XHTML to PDF in C#


In this blog post I will illustrate how you could convert an XHTML page into PDF using the flying-saucer library. This is a Java library so we need to first step would be to convert it to a .NET assembly.

I will use the IKVM.NET Bytecode Compiler (ikvmc.exe) for this purpose. So go ahead and download both the flying-saucer library and the IKVM project. Then run the following command:

ikvmc.exe -target:library -out:CoreRenderer.dll iText-2.0.8.jar core-renderer.jar

This will generate the CoreRenderer.dll assembly which could be used. And finally we would create an application which would use it inside a console application:sourcecode395858614


One last step is to ensure that you have referenced the following assemblies:


Those assemblies are part of the IKVM project and have dependencies on many other assemblies that are included with it. So the final folder should contain all those:


And that’s pretty much all. When you run the console application it should generate the output PDF file.

This post is also available in %s.

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “How to convert XHTML to PDF in C#”