Saves a specific PDF page or range of pages 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,
	int fromPage,
	int toPage
)
Public Function ToWord ( _
	fileName As String, _
	fromPage As Integer, _
	toPage As Integer _
) As Integer

Parameters

fileName
String
Path to the Word file
fromPage
Int32
The starting page for export in Word document
toPage
Int32
The ending page for export in Word document

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 diapason of PDF pages to Word file in C#
using System;
using System.IO;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            string pathToPdf = @"..\..\..\..\..\simple text.pdf";
            string pathToWord = Path.ChangeExtension(pathToPdf, ".rtf");

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

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                // You may set an output format to docx or rtf.
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;

                // Convert only pages 2 - 4 to Word.
                int result = f.ToWord(pathToWord, 2, 4);

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

Module Sample

    Sub Main()
        Dim pathToPdf As String = "..\..\..\..\simple text.pdf"
        Dim pathToWord As String = Path.ChangeExtension(pathToPdf, ".rtf")

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


        f.OpenPdf(pathToPdf)

        If f.PageCount > 0 Then
            ' You may set an output format to docx or rtf.
            f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf

            ' Convert only pages 2 - 4 to Word.
            Dim result As Integer = f.ToWord(pathToWord, 2, 4)

            ' Show Word document
            If result = 0 Then
                System.Diagnostics.Process.Start(pathToWord)
            End If
        End If
    End Sub
End Module

See Also