Closed jitutrivedi closed 5 years ago
Do you have Microsoft Word installed on your web server?
No not installed ! Please Help if possible .. I create word document using Openxml now try to convert Pdf using Netoffice
You must have Microsoft Word installed to work with Word.Application
any other solution to convert docx to Pdf without installation of Word.Application ?
`using NetOffice; using Word = NetOffice.WordApi; using NetOffice.WordApi.Enums;
using NetOffice.OfficeApi.Tools;
using EagleEyeWeb.Models;
` public ActionResult Paperview(string fname) {
if (fname == string.Empty || fname == null)
{
ViewBag.msg = "File Creattion Fail";
return View();
}
else
{
Word.Application wordApplication = new Word.Application();
wordApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone;
// create a utils instance, no need for but helpful to keep the lines of code low
CommonUtils utils = new CommonUtils(wordApplication);
string path1 = Server.MapPath("~/Files/") + fname + ".docx";
string path2 = Server.MapPath("~/Files/") + fname + ".pdf";
Word.Document newDocument = wordApplication.Documents.Open(path1);
newDocument.SaveAs2(path2, WdSaveFormat.wdFormatPDF);
newDocument.Close(WdSaveOptions.wdDoNotSaveChanges);
wordApplication.Quit(WdSaveOptions.wdDoNotSaveChanges);
newDocument.Dispose();
wordApplication.Dispose();
ViewBag.msg = "File Creattion Success";
return View();
}
}
Error Occurs When Published to web host ArgumentException: progId not found. Word.Application
I am try to Convert Docx to Pdf
` public ActionResult Paperview(string fname) {
`