i am using NReco html to pdf converter for my project. It is giving me error for 3 days on server machine,it was working for months without any problem.Worse thing is , the project is working well on my local pc with same codes.I guess, the problem is related with some folder autorization or temp files which is already created on server pc.I have also deleted temp files under /user and windows/temp folders but still getting error:
the simple error message is : "The file exists"
Code:
public static byte[] ToPDF(this HttpContext context, string htmlContent )
{
string logFile = context.Request.PhysicalApplicationPath + "\\" + "log.txt";
try
{
var converter = new HtmlToPdfConverter();
converter.Margins = new PageMargins { Bottom = 20, Top = 18 };
var pdfBytes = converter.GeneratePdf(htmlContent); //THROW EXCEPTION ON THIS LINE
errorMsg = "Error Code:00x1";
return null;
}
catch (Exception exp)
{
errorMsg = "Error Code:00x2";
CreateErrorLog(context ,exp);
return null;
}
}
I have fixed it by updating NReco.PdfGenerator.dll to version to 1.1.11.0 , was using out-of date version(released 3 years ago) and error has gone.
Note: When i uninstall and install Nreco using Nuget Package manager , it is installed same old version , i don't know why so i had to download it from :
https://pdfgenerator.codeplex.com/
and manually remove old .dll from Project's references and add new NReco.PdfGenerator.dll