protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string extention = Path.GetExtension(FileUpload1.PostedFile.FileName);
if (extention.ToLower() == ".doc" || extention.ToLower() == ".docx")
{
string path = System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName);
string filename = TextBox1.Text;
FileUpload1.SaveAs(Server.MapPath("pdf\\") + filename);
ConvertTopdf(path, filename);
Label1.Text = "File upload Successfull";
}
else
{
Label1.Text = "Please Select the word file only";
}
}
else
{
Label1.Text = "Please Selet the File";
}
}
public void ConvertTopdf(string path, string filename)
{
SautinSoft.UseOffice u = new SautinSoft.UseOffice();
if (u.InitWord() == 0)
{
u.ConvertFile(path, Server.MapPath("pdf\\") + filename, SautinSoft.UseOffice.eDirection.DOC_to_PDF);
}
u.CloseOffice();
}
What I have tried:
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string extention = Path.GetExtension(FileUpload1.PostedFile.FileName);
if (extention.ToLower() == ".doc" || extention.ToLower() == ".docx")
{
string path = System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName);
string filename = TextBox1.Text;
FileUpload1.SaveAs(Server.MapPath("pdf\\") + filename);
ConvertTopdf(path, filename);
Label1.Text = "File upload Successfull";
}
else
{
Label1.Text = "Please Select the word file only";
}
}
else
{
Label1.Text = "Please Selet the File";
}
}
public void ConvertTopdf(string path, string filename)
{
SautinSoft.UseOffice u = new SautinSoft.UseOffice();
if (u.InitWord() == 0)
{
//convert Word (RTF, DOC, DOCX to PDF)
u.ConvertFile(path, Server.MapPath("pdf\\") + filename, SautinSoft.UseOffice.eDirection.DOC_to_PDF);
}
u.CloseOffice();
}