How to convert XHTML to PDF in C#

Envoyer Imprimer PDF
Note des utilisateurs: / 21
MauvaisTrès bien 
There are no translations available.

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:


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

todelka


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:

todelka2

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

Mise à jour le Mercredi, 02 Mars 2011 22:36