Creates an object of the UseOffice class

Namespace:  SautinSoft
Assembly:  UseOffice (in UseOffice.dll) Version: 4.3.12.15

Syntax

      
 C#  Visual Basic 
public UseOffice()
Public Sub New

Remarks



Examples

CopyHow to convert a PDF file to a DOC file in C#
using System;
using System.IO;
using System.Collections;
using SautinSoft;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Convert PDF file to DOC file. Works only in Office 2013 and higher.
            // If you are looking for PDF to Word solution independent from MS Office
            // You may take a look at: http://www.sautinsoft.com/products/pdf-focus/index.php

            SautinSoft.UseOffice u = new SautinSoft.UseOffice();                       

            // Input PDF document path
            string inFile = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(),@"..\..\..\..\..\..\Testing files\simple text.pdf"));
            // Path to an output file
            string outFile = Path.ChangeExtension(inFile, ".doc");

            // Prepare UseOffice .Net, loads MS Word in memory
            if (u.InitWord() != 0)
            {
                Console.WriteLine("Error: Can't load MS Word in memory!");
                Console.WriteLine("Please contact SautinSoft's support Team: support@sautinsoft.com.");
                Console.ReadLine();
            }

            // Check MS Office version
            if (u.OfficeVersion >= UseOffice.eOfficeVersion.Office2013)
            {
                // Converting ...
                int result = u.ConvertFile(inFile, outFile, UseOffice.eDirection.PDF_to_DOC);

                if (result == 0)
                {
                    Console.WriteLine("Converting succesuflly!");
                    System.Diagnostics.Process.Start(outFile);
                }
                else
                    Console.WriteLine("Converting failed!");
            }
            else
            {                
                Console.WriteLine("To convert PDF documents, please install MS Office 2013 or higher.");
                Console.ReadLine();
            }

            u.CloseOffice();
        }
    }
}
CopyHow to convert a PDF file to a DOC file in VB.Net
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections
Imports SautinSoft


Module Module1
    Sub Main()
        ' Convert PDF file to DOC file. Works only in Office 2013 and higher.
        ' If you are looking for PDF to Word solution independent from MS Office
        ' You may take a look at: http://www.sautinsoft.com/products/pdf-focus/index.php


        Dim u As New SautinSoft.UseOffice()

        ' Input PDF document path
        Dim inFile As String = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..\..\..\..\..\Testing files\simple text.pdf"))
        ' Path to an output file
        Dim outFile As String = Path.ChangeExtension(inFile, ".doc")

        ' Prepare UseOffice .Net, loads MS Word in memory
        If u.InitWord() <> 0 Then
            Console.WriteLine("Error: Can't load MS Word in memory!")
            Console.WriteLine("Please contact SautinSoft's support Team: support@sautinsoft.com.")
            Console.ReadLine()
        End If

        ' Check MS Office version
        If u.OfficeVersion >= UseOffice.eOfficeVersion.Office2013 Then
            ' Converting ...
            Dim result As Integer = u.ConvertFile(inFile, outFile, UseOffice.eDirection.PDF_to_DOC)

            If result = 0 Then
                Console.WriteLine("Converting succesuflly!")
                System.Diagnostics.Process.Start(outFile)
            Else
                Console.WriteLine("Converting failed!")
                Console.ReadLine()
            End If
        Else
            Console.WriteLine("To convert PDF documents, please install MS Office 2013 or higher.")
            Console.ReadLine()
        End If

        u.CloseOffice()
    End Sub
End Module

See Also