0

iam new here and hope someone can help me out.

iam trying to convert a html string to a pdf version in net5. We had it running in net core 2.2 without any problems. Now we are trying to migrate everything to net5. Well the only part which is not working anymore is converting html string to pdf document.

We are using following nuget package: Select.HtmlToPdf.NetCore As soon we try the convert the html string with "ConvertHtmlString" we get following Exception.

System.ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name'

here is a simple snippet to repdoruce the problem:

var htmlString = "<html><head></head><body>Test me out!</body></html>";
var converter = new HtmlToPdf();
converter.Options.PdfPageSize = PdfPageSize.Letter;
converter.Options.AutoFitWidth = HtmlToPdfPageFitMode.AutoFit;
converter.Options.AutoFitHeight = HtmlToPdfPageFitMode.AutoFit;
converter.Options.PdfPageOrientation = PdfPageOrientation.Landscape;
SelectPdf.PdfDocument doc = converter.ConvertHtmlString(htmlString);
doc.Save("C:\\Temp\\test.pdf");
doc.Close();

Thanks.

Regards Maik

Maik
  • 1
  • 1
  • 1
  • 1
    Your code works properly with me. Makes sure you installed the proper NuGet package Select.HtmlToPdf.NetCore – Mahmoud Nasr May 02 '21 at 15:12
  • Hi thanks for your comment... ive created a clean new project and tried it.. it works.. i need to check why it is not working in my other solution. If i find anything i will write it here – Maik May 02 '21 at 17:01

1 Answers1

0

Ok thx for the hint in the comment..

before i posted my question i did some standard stuff i always do before researching deeper..

Clean solution, restarted VisualStudio and so on.. nothing worked. Ive checked my nuget packages and i had the correct one installed.

I removed the package and reinstalled it again and well it works now. Cant exactly say what the problem was but.. it works now.

Maik
  • 1
  • 1
  • 1