USe Microsoft Primary Interop Libraries for converting DataTable to PDF.
public bool ConvertWordToPdf(object source, object target)
{
if (_wordDocument == null)
{
_wordDocument = new Microsoft.Office.Interop.Word.ApplicationClass();
}
try
{
_wordDocument.Documents.Open(ref source, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown);
_wordDocument.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize;
object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
_wordDocument.ActiveDocument.SaveAs(ref target, ref format, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown, ref _unknown);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
if (_wordDocument != null)
{
_wordDocument.Documents.Close(ref _unknown, ref _unknown, ref _unknown);
}
_wordDocument.Quit(ref _unknown, ref _unknown, ref _unknown);
}
return true;
}
//Use the above function as described below
var obj = new ConvertMethodHelper();
const string source = @"C:\Test\Prod20131107141635558.doc";
const string destination = @"C:\Test\word07.pdf";
bool checkMethodExecStatus=obj.ConvertWordToPdf(source, destination);