Convert PDF to Word document using C# and VB.Net in ASP.Net

Last Reply 4 months ago By dharmendr

Posted 4 months ago

Hello,

How to convert PDF file to word in ASP.Net and C#?

Posted 4 months ago

Hi KatieNgoc,

Check this example. Now please take its reference and correct your code.

C#

string pdfFile = Server.MapPath("~/Files/Test.pdf");
string wordFile = Server.MapPath("~/Files/Test.docx");
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.OpenPdf(pdfFile);
if (f.PageCount > 0)
{
    // You may choose output format between Docx and Rtf. 
    f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;
    f.ToWord(wordFile);
}

VB.Net

Dim pdfFile As String = Server.MapPath("~/Files/Test.pdf")
Dim wordFile As String = Server.MapPath("~/Files/Test.docx")
Dim f As SautinSoft.PdfFocus = New SautinSoft.PdfFocus()
f.OpenPdf(pdfFile)
If f.PageCount > 0 Then
    f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx
    f.ToWord(wordFile)
End If

You have to download the SautinSoft.PdfFocus.dll from the below link. A sample also provided.

https://code.msdn.microsoft.com/How-to-convert-PDF-to-DOCX-fc9e7186#content