Saves all pages of the PDF document in Text document and returns it as string

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

Syntax

      
 C#  Visual Basic 
public string ToText()
Public Function ToText As String

Return Value

String with Unicode Text - in case of converting successful
null - in case of converting failed

Remarks

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



Examples

CopyASP.Net - Extract Text from PDF in C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox1.Text = "";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile.FileName.Length == 0 || FileUpload1.FileBytes.Length == 0)
        {
            TextBox1.Text = "Please select PDF file at first!";
            return;
        }

        SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
        //this property is necessary only for registered version
        //f.Serial = "XXXXXXXXXXX";
        f.OpenPdf(FileUpload1.FileBytes);

        if (f.PageCount > 0)
        {
            //Convert whole PDF to Text (extract text from PDF)
            string text = f.ToText();

            //show text
            TextBox1.Text = text;
        }
        else
        {
            TextBox1.Text = "Extracting failed!";
        }
    }
}
CopyASP.Net - Extract Text from PDF in VB.Net
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO

Partial Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        TextBox1.Text = ""
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        If FileUpload1.PostedFile.FileName.Length = 0 OrElse FileUpload1.FileBytes.Length = 0 Then
            TextBox1.Text = "Please select PDF file at first!"
            Return
        End If

        Dim f As New SautinSoft.PdfFocus()
        'this property is necessary only for registered version
        'f.Serial = "XXXXXXXXXXX"


        f.OpenPdf(FileUpload1.FileBytes)

        If f.PageCount > 0 Then
            'Convert whole PDF to Text (extract text from PDF)
            Dim text As String = f.ToText()

            'show text
            TextBox1.Text = Text

        Else
            TextBox1.Text = "Converting failed!"
        End If
    End Sub
End Class

See Also