CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2013
    Posts
    28

    Thumbs up Select text from .pdf file and show it on the Richtext box. ? Its Challanging....

    Hi all,

    i am having 3 controls.
    Button
    AxAcroPDF1
    Richtextbox

    I select text from pdf file present in AxAcroPDF1 from mouse click, what ever i select immidiately it show be shown on the text on the Richtextbox
    Code:
     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    
            Dim dlg As OpenFileDialog = New OpenFileDialog()
            ' set file filter of dialog
            dlg.Filter = "pdf files (*.pdf) |*.pdf;"
            dlg.ShowDialog()
            If dlg.FileName <> "" Then
                AxAcroPDF1.src = dlg.FileName
    
            End If
        End Sub
    Will be waiting for the reply.

    Kind Regards
    Seema

  2. #2
    Join Date
    Jan 2013
    Posts
    28

    Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...

    Mean while i just got 1 site in which i found the below code.... But i dnt know how to make it work... so many things r strange i am not getting them how to do... Ur help will be appriciated...
    Code:
      CAcroAVDoc avDoc;
                CAcroPDDoc pdDoc;
                CAcroRect acroRect = new AcroRectClass();
                CAcroPDTextSelect pdTextSelect;
                int startpage;
                bool bSelectSet = false;
                bool bShowSelect = false;
     
                string szPdfConst = openDialog.FileName;
     
    
                acroRect.bottom = 225;
                acroRect.Left = 140;
                acroRect.Top = 230;
                acroRect.right = 145;
     
                //Create a new Acrobat App Object
     
                mApp = new AcroAppClass();
                mApp.Show();
                avDoc = new AcroAVDocClass();
     
                //Lets open the PDF now
                if (avDoc.Open(szPdfConst, ""))
                {
                    fileStatus.Text = "Adobe Acrobat document loaded succesfully.";
                    pdDoc = (CAcroPDDoc)avDoc.GetPDDoc();
                    startpage = 0;
     
                    pdTextSelect = (CAcroPDTextSelect)pdDoc.CreateTextSelect(startpage, acroRect);
    
                    bSelectSet = avDoc.SetTextSelection(pdTextSelect);
    
                    //If the set was successful
                    if (bSelectSet)
                    {
                        bShowSelect = avDoc.ShowTextSelect();
                    }
                }
                else
                {
                    fileStatus.Text = "Adobe Acrobat document could not be loaded.";
                }
            }
    The link is http://forums.adobe.com/thread/567307

  3. #3
    Join Date
    Jan 2013
    Posts
    28

    Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...

    Quote Originally Posted by SeemsP View Post
    Mean while i just got 1 site in which i found the below code.... But i dnt know how to make it work... so many things r strange i am not getting them how to do... Ur help will be appriciated...
    Code:
      CAcroAVDoc avDoc;
                CAcroPDDoc pdDoc;
                CAcroRect acroRect = new AcroRectClass();
                CAcroPDTextSelect pdTextSelect;
                int startpage;
                bool bSelectSet = false;
                bool bShowSelect = false;
     
                string szPdfConst = openDialog.FileName;
     
    
                acroRect.bottom = 225;
                acroRect.Left = 140;
                acroRect.Top = 230;
                acroRect.right = 145;
     
                //Create a new Acrobat App Object
     
                mApp = new AcroAppClass();
                mApp.Show();
                avDoc = new AcroAVDocClass();
     
                //Lets open the PDF now
                if (avDoc.Open(szPdfConst, ""))
                {
                    fileStatus.Text = "Adobe Acrobat document loaded succesfully.";
                    pdDoc = (CAcroPDDoc)avDoc.GetPDDoc();
                    startpage = 0;
     
                    pdTextSelect = (CAcroPDTextSelect)pdDoc.CreateTextSelect(startpage, acroRect);
    
                    bSelectSet = avDoc.SetTextSelection(pdTextSelect);
    
                    //If the set was successful
                    if (bSelectSet)
                    {
                        bShowSelect = avDoc.ShowTextSelect();
                    }
                }
                else
                {
                    fileStatus.Text = "Adobe Acrobat document could not be loaded.";
                }
            }
    The link is http://forums.adobe.com/thread/567307
    Well i reached to the point here that i think using AVDoc , PDDoc - we cn copy the text... i m not sure... Plz help me it v urget


    Code:
       Dim PDDoc As Object
            Dim AVDoc As Object
            Dim AcroExchApp As Object
    
    
            AcroExchApp = CreateObject("AcroExch.App")
            AVDoc = AcroExchApp.GetActiveDoc
            PDDoc = AVDocTarget.GetPDDoc
    
            If PDDoc.Save(PDSaveFull, "c:\test.pdf") = False Then
                MsgBox("Unable to save image")
            Else : MsgBox("The file is saved")
            End If

  4. #4
    Join Date
    Mar 2014
    Posts
    6

    Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...

    Quote Originally Posted by SeemsP View Post
    Hi all,

    i am having 3 controls.
    Button
    AxAcroPDF1
    Richtextbox

    I select text from pdf file present in AxAcroPDF1 from mouse click, what ever i select immidiately it show be shown on the text on the Richtextbox
    Have you ever thought using pdf text coordinate system to select text from pdf?

  5. #5
    Join Date
    Jun 2015
    Posts
    1

    Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...

    I searched internet and found the following thread that might help you to get Text from axAcroPDF control:
    https://social.msdn.microsoft.com/Fo...=csharpgeneral

    I am currently using leadtools SDK to extract text from pdf documents using PDFDocument class. I found the following page that might help:
    https://www.leadtools.com/help/leadt...arsepages.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured