Saves all pages of the PDF document in Word file

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 6.6.9.7 (6.6.9.7)

Syntax

      
 C#  Visual Basic 
public int ToWord(
	string fileName
)
Public Function ToWord ( _
	fileName As String _
) As Integer

Parameters

fileName
String
Path to the Word file

Return Value

0 - saving successfully
2 - can't create output file, check the output path
3 - problem with rendering of Word (Docx or RTF) document. Please email this PDF document at support@sautinsoft.com.

Remarks

To start the process, please download the most fresh version of PDF Focus .Net.

Before converting you may set some properties for produced Word document using the property WordOptions

For example, set:
  • Format - set format for resulting Word document


Examples

CopyConvert PDF file to Word file in C#
using System;
using System.IO;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            string pdfFile = @"..\..\..\..\..\text and graphics.pdf";
            string wordFile = Path.ChangeExtension(pdfFile, ".docx");

            // Convert a PDF file to a Word file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // You may choose output format between Docx and Rtf.
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;

                int result = f.ToWord(wordFile);

                // Show the resulting Word document.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(wordFile);
                }
            }
        }
    }
}
CopyConvert PDF file to Word file in VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft

Module Sample

    Sub Main()
        Dim pdfFile As String = "..\..\..\..\text and graphics.pdf"
        Dim wordFile As String = Path.ChangeExtension(pdfFile, ".docx")

        ' Convert a PDF file to a Word file
        Dim f As New SautinSoft.PdfFocus()
        'this property is necessary only for registered version
        'f.Serial = "XXXXXXXXXXX";


        f.OpenPdf(pdfFile)

        If f.PageCount > 0 Then
            ' You may choose output format between Docx and Rtf.
            f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx

            Dim result As Integer = f.ToWord(wordFile)

            ' Show the resulting Word document.
            If result = 0 Then
                System.Diagnostics.Process.Start(wordFile)
            End If
        End If

    End Sub
End Module

See Also