The type initializer for 'spr᧹' threw an exception.
this is my Code !
- Code: Select all
public static byte[] ConvertDocToPdf(byte[] bytesDoc)
{
if (bytesDoc != null)
{
const string strFileName = "Job-Description";
string strPath = HostingEnvironment.MapPath("~/assets/Preview_Job_Description");
if (strPath != null && !Directory.Exists(strPath))
Directory.CreateDirectory(strPath);
strPath += "/" + strFileName+".docx";
System.IO.File.WriteAllBytes(strPath, bytesDoc);
Spire.Doc.Document document = new Spire.Doc.Document();
document.LoadFromFile(strPath);
//Convert Word to PDF
document.SaveToFile("~/assets/Preview_Job_Description/toPDF.PDF", FileFormat.PDF);
byte[] pdfBytes =System.IO.File.ReadAllBytes(HostingEnvironment.MapPath("~/assets/Preview_Job_Description/toPDF.PDF"));
return pdfBytes;
}
else
{
bytesDoc = new byte[0];
const string strFileName = "Job-Description";
string strPath = HostingEnvironment.MapPath("~/assets/Preview_Job_Description");
if (strPath != null && !Directory.Exists(strPath))
Directory.CreateDirectory(strPath);
strPath += "/" + strFileName;
System.IO.File.WriteAllBytes(strPath + ".doc", bytesDoc);
return bytesDoc;
}
}