PdfFocusToWord(String, Int32, Int32) Method |
Saves the specific PDF page or range of pages in
Word file.
Namespace: SautinSoftAssembly: SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 2024.12.2
Syntax 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
Int32
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
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
Example Convert diapason of PDF pages to Word file in C#
using System;
using System.IO;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
string inpFile = Path.GetFullPath(@"..\..\..\Potato Beetle.pdf");
string outFile = "Result.rtf";
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.OpenPdf(inpFile);
if (f.PageCount > 0)
{
f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;
f.RenderPagesString = "2-4, 6";
f.RenderPages = new int[][] {new int[] {2, 4},
new int[] {6, 6}};
int result = f.ToWord(outFile);
if (result == 0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
}
}
}
}
}
Convert 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 inpFile As String = Path.GetFullPath("..\..\..\Potato Beetle.pdf")
Dim outFile As String = "Result.rtf"
Dim f As New SautinSoft.PdfFocus()
f.OpenPdf(inpFile)
If f.PageCount > 0 Then
f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf
f.RenderPagesString = "2-4, 6"
f.RenderPages = New Integer()() {
New Integer() {2, 4},
New Integer() {6, 6}
}
Dim result As Integer = f.ToWord(outFile)
If result = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
End If
End If
End Sub
End Module
See Also