I need to convert some html to a PDF. I came across IText7 and it looks a good solution.
I am developing in .net core 3.1
But, even using a basic implementation of it I am getting an error:
string basicPage = "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>"; using (FileStream pdfDest = File.Open(@"C:\Users\Trevo\Desktop\output.pdf", FileMode.OpenOrCreate)) { ConverterProperties converterProperties = new ConverterProperties(); HtmlConverter.ConvertToPdf(basicPage, pdfDest, converterProperties); } The error is everyone's favourite of:
Object reference not set to an instance of an object.
The inner exception is null and the only clue is the SerializationStackTraceString is:
at iText.IO.Font.FontCache..cctor()
So, it's pointing towards something to do with font?
The only suggestion I have found was to clean various directories and caches. I have created a clean solution from scratch and the same error occurs.
Can anyone offer any help please?
AppDomain.CurrentDomain.AssemblyResolveevent, you can see if the AppDomain is trying to resolve (look for) an assembly that it cannot find. Here is the link: learn.microsoft.com/en-us/dotnet/api/…