Maik
Maik

Reputation: 1

Converting Html to Pdf with SelectPdf ArgumentNullException

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

Upvotes: 0

Views: 4430

Answers (1)

Maik
Maik

Reputation: 1

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.

Upvotes: 0

Related Questions