I have an situation where i need to convert Doc file into PDF file. I am devepoing windows application in vb.net. and also i don\'t want to user third party dll if possible.
You can get idea in my code, I generate file from word template file save file as pdf using Office.Interop. Dont forget to add reference the office.Interop.Word
sFileName = "billing"
wdApp = New Word.Application
wdDocs = wdApp.Documents
Dim wdDoc As Word.Document = wdDocs.Add(sPath & "template.dotx")
Dim wdBooks As Word.Bookmarks = wdDoc.Bookmarks
Dim wdTable As Word.Table
Dim r As Integer, c As Integer
wdTable = wdDoc.Tables.Add(wdDoc.Bookmarks.Item("bkTable").Range, 3, 6)
Dim rowCOunt As Integer = dgvSample.Rows.Count, colCount As Integer = dgvSample.Columns.Count
'DATAGRIDVIEW TO WORDTABLE
For r = 1 To rowCOunt
For c = 1 To colCount
wdTable.Cell(r, c).Range.Text = dgvSample.Rows(r - 1).Cells(c - 1).Value
Next
Next
wdTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
wdTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
wdBooks("bkClient_name").Range.Text = txtClient.Text.ToString
wdBooks("bkDate").Range.Text = dtpDate.Text.ToString
wdDoc.SaveAs2(sPath & sFileName & ".pdf", Word.WdSaveFormat.wdFormatPDF)
ReleaseObject(wdBooks)
wdDoc.Close(False)
ReleaseObject(wdDoc)
ReleaseObject(wdDocs)
wdApp.Quit()