Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jun 06, 2018 8:53 pm

Hello everyone, I'm trying to extract a text from a rectangular area of ​​a PDF file, but I can not, could they please help me? I tried this way:
Code: Select all
        area = New RectangleF(2.3, 99, 322.5, 9.8)
        page = pdf.Pages(0)
        name = page.ExtractText(area)

agok
 
Posts: 3
Joined: Tue May 29, 2018 2:53 pm

Thu Jun 07, 2018 3:29 am

Dear agok,

Thanks for your inquiry.
Please make sure if the rectangle area is correct that could extract text. If you still has the issue, in order to help us investigate further, please share us your input PDF and point out where you want to extract text.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Jun 08, 2018 11:07 am

Here is the file I am trying to extract the text from, the field in yellow is what is in the area selected in this example, the error I am getting is the following:
Code: Select all
Error  Value of type 'System.Drawing.RectangleF' can not be converted to 'Integer'.


This is the complete code:
Code: Select all
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports Spire.Pdf
Public Class Form1
    Dim pdf As New PdfDocument
    Dim caminho As String
    Dim nome As String
    Dim area As RectangleF
    Dim page As PdfPageBase

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
        caminho = OpenFileDialog1.FileName
        pdf.LoadFromFile(caminho)
        area = New RectangleF(2.3, 99, 322.5, 9.8)
        page = pdf.Pages(0)
        nome = page.ExtractText(area)
        'This is just a test to verify that the extraction is working.
        MsgBox(nome)
    End Sub
End Class

agok
 
Posts: 3
Joined: Tue May 29, 2018 2:53 pm

Mon Jun 11, 2018 2:32 am

Dear agok,

Thanks for your information and sorry for late reply as weekend.
After testing your case with the latest Spire.PDF Pack(Hot Fix) Version:4.6.1, it worked fine. Please use this version and try agian.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jun 11, 2018 12:12 pm

I tested with this new package and it worked perfectly. Thank you very much for your attention.

agok
 
Posts: 3
Joined: Tue May 29, 2018 2:53 pm

Tue Jun 12, 2018 1:34 am

Dear agok,

Thanks for your feedback.
Any question, just feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF